我有一个复选框,我想让我的复选框默认选中,如果用户取消选中复选框并保存表单,我需要在检索或编辑表单数据时取消选中该复选框。
我的查看页面
<div class="form-group {{ $errors->has('active') ? 'error' : '' }}">
<label for="active" class="col-md-3 control-label">@lang('admin/assetdetails/form.active')</label>
<div class="controls col-md-7">
{{ Form::checkbox('active', 1, Input::old('active', $assetdetail->active), array('class'=>'isnesdbox')) }}
{{ $errors->first('active', '<span class="alert-msg"><i class="icon-remove-sign"></i> :message</span>') }}
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
给这个正确地从数据库中带回旧数据,但我无法将我的复选框选中为默认值
控制器:
public function postEdit($assetdetailId = null)
{
// Check if the location exists
if (is_null($assetdetail = Assetdetail::find($assetdetailId)))
{
// Redirect to the blogs management page
return Redirect::to('admin/settings/assetdetails')->with('error', Lang::get('admin/assetdetails/message.does_not_exist'));
}
// get the POST data
$new = Input::all();
// attempt validation
if ($assetdetail->validate($new))
{
// Update …Run Code Online (Sandbox Code Playgroud)