{!! Form :: select(' grade',array('' =>' Select A Grade')+ $ grade,null,[' class& #39; =>'表格控制',' id' =>'等级'])!!}
以上是投递箱代码。在那里,我还需要将选项值设置为从db检索的值。我怎么能这样做?
答案 0 :(得分:0)
试试这个:
在控制器中:
Class yourController extends Controller {
protected $gradeList;
public function __construct() {
$this->gradeList = ['' => 'Select A Grade'] + Grade::lists('name', 'id')->all();
}
// suppose you want to get it i index method
public function index() {
$gradeArray = $this->gradeList;
return view('yourBladeTemplate', compact('gradeArray');
}
}
在刀片模板中
{!! Form::select('id', $gradeArray , Input::old('id') , array('class'=>'form-control')) !!}