Laravel select form default value

2.5k views Asked by At

I'm having problem on setting the default value of "Please Select" on my select form from laravel. here comes the code.

$user = \App\User::where('role_id','=','3')->orderBy('name', 'ASC')->lists('name','staff_id');

and here's on my blade

{!! Form::select('requestby', $user, Input::old('requestby'), array('class' => 'form-control')) !!}

i have tried to put the array_merge but it seems like it is overwriting the <option> value from staff_id to index value. what should i do now?

1

There are 1 answers

0
Sougata Bose On BEST ANSWER

array_merge will re-index the array when merging. You can use + for this -

$user = array('' => 'Please Select') + $user;

The indexs will not be changed.