Laravel 5 未在控制器中提交复选框值-Laravel
我的控制器操作方法如下:Laravel 5 未在控制器中提交复选框值-Laravel,laravel-5,laravel-5.1,Laravel 5,Laravel 5.1,我的控制器操作方法如下: public function store(Request $request) { $IsActive = $request->input('IsActive'); echo $IsActive; die(); } 我的观点如下 {!! Form::open(array('method' => 'POST', 'action' => 'DepartmentController@store')) !!} {!! For
public function store(Request $request)
{
$IsActive = $request->input('IsActive');
echo $IsActive;
die();
}
我的观点如下
{!! Form::open(array('method' => 'POST', 'action' => 'DepartmentController@store')) !!}
{!! Form::checkbox('IsActive', 0, null, array('class' => "flat")) !!}
{!! Form::submit('Save', array('class' => "btn btn-success"))!!}
{!! Form::close() !!}
问题
在表单提交时,复选框的值始终为0。我失踪了吗
什么
您在表单提交中得到的值是
0
,因为您已明确声明值为0
。将0
替换为您想要的任何值,您将根据自己的意愿获得结果
从:
希望这对你有所帮助
/**
* Create a checkbox input field.
*
* @param string $name
* @param mixed $value
* @param bool $checked
* @param array $options
* @return string
*/
public function checkbox($name, $value = 1, $checked = null, $options = array())
{
return $this->checkable('checkbox', $name, $value, $checked, $options);
}
/**
* Create a checkable input field.
*
* @param string $type
* @param string $name
* @param mixed $value
* @param bool $checked
* @param array $options
*
* @return string
*/
protected function checkable($type, $name, $value, $checked, $options)
{
$checked = $this->getCheckedState($type, $name, $value, $checked);
if ($checked) {
$options['checked'] = 'checked';
}
return $this->input($type, $name, $value, $options);
}