以下是我在视图中的代码,我想在编辑视图中显示包含所选数据的下拉列表。
{{Form::select('Select_targets[]', $_targets,Input::old('Select_target', $profile->Target_idTarget-1), array('multiple' => true))}}
我尝试了这段代码,但它只显示了一个选定的值。拜托我需要你的帮忙! 提前致谢
答案 0 :(得分:2)
我认为您的旧输入和下拉列表的默认值都有错误。这是一个有效的例子:
控制器:
//current selected
$target = 3;
/array with options
$targets[1] = 'target 1';
$targets[2] = 'target 2';
$targets[3] = 'target 3';
return View::make('form')->with('targets',$targets)->with('target',$target);
查看:
{{ Form::open() }}
{{ Form::select('targets[]', $targets, Request::old('targets') ? Request::old('targets') : $target, array('multiple' => true)); }}
{{ Form::submit('send') }}
{{ Form::close() }}