Reputation: 277
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?
Upvotes: 1
Views: 2510
Reputation: 31739
array_merge
will re-index the array when merging. You can use +
for this -
$user = array('' => 'Please Select') + $user;
The index
s will not be changed.
Upvotes: 2