Select box with first option empty

后端 未结 15 1039
情深已故
情深已故 2021-02-01 16:29

Does anybody know how can I set in my select box the first option to empty value?

I\'m getting the data from my DB, and I would like to set the option by default as \"P

15条回答
  •  时光说笑
    2021-02-01 16:50

    in controller

    $data['options']=Entity::pluck('name','id')->prepend('Please Select','');
    
    return view('your_view_blade',$data);
    

    in view blade

    {!! Form::select('control_name',$options,null,['class'=>'your_class']) !!}
    

提交回复
热议问题