Search code examples
phphtmllaravelformbuilder

how to set the selected option using illuminate Form


I am using the HtmlServiceProvider in laravel 5.1 to build my form , I want to set the selected option in select dropdown list tag when I get the data from my model class

My code so far:

{!! Form::model($advertisment,['url'=>'dashboard/edit/advertisment']) !!}
{!! Form::select('Gender', [""=>'Select Gender',"Male"=>'Male', "Female"=>'Female'],0, ['class' => 'form-control', 'id' => 'form_control_6' ,'required']) !!}
{!! Form::close() !!}

Solution

  • If you don't want to override the value from the model, pass in null