本文介绍了Laravel-重新填充复选框以勾选或取消勾选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Laravel中,如果验证失败,它将返回到同一表单页面.如何重新填充复选框以勾选或取消勾选?

In Laravel, if validation failed, it goes back to a same form page. How to repopulate a checkbox to ticked or unticked?

默认情况下,初次在页面上加载时应取消勾选.

By default, it should be unticked when loading on the page for the first time.

{{ Form::checkbox('custom_address', false,
   Input::old('custom_address'), array('class' => 'test')); }}

推荐答案

您需要为复选框设置一个值,否则Input类将始终使其为空/未选中​​.

You need to set a value for your checkbox, otherwise the Input class will always have it empty / unchecked.

将复选框的值设置为1,则它应该可以正常工作.

Give the checkbox a value of 1, then it should work.

{{ Form::checkbox('custom_address', 1, Input::old('custom_address'), array('class' => 'test')); }}

这篇关于Laravel-重新填充复选框以勾选或取消勾选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-23 04:06