phplaravelhomesteadlaravelcollective

Laravel - Select input not keeping old value


I have a piece of code:

{!! Form::select('option_employee_review', old('option_employee_review', $employeeReviews), $employeeReviews, ['id' => 'option_employee_review', 'class' => 'form-control ']); !!}

It saves the value to the database correct. When i go to edit the item again the select input does not keep the old value that's in the database. How do i make it so that the select input does keep its old value.

$employeeReviews:

[
  2843 => "Medewerker review 1"
  2849 => "Medewerker review 2"
]

Solution

  • I am not using your syntax, but something like this will do I think.

    <option value="{{$channel->id}}" {{ (old("channel_id") == $channel->id ? "selected" : "" ) }}>{{$channel->title}}</option>