Change the null (3rd) argument to the saved worktypes; e.g.
{!!Form::select('worktype_id[]', $worktypes_list, $thing->worktypes->pluck('id'), ['class' => 'form-control'])!!}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm using Laravel Collective Form builder in my view and i'm populating this select box from a table in my DB like this
{!!Form::select('worktype_id[]', $worktypes_list, null, ['class' => 'form-control'])!!}
In my controller i have this for populating that select box
$worktypes_list = Worktype::lists('id', 'name');
return view('edit')->compact(''worktypes_list');
Now when i want to edit the selected item is always the first one and it should be the one that is saved in DB.
How to make selected item to be the one which is saved in DB?
Change the null (3rd) argument to the saved worktypes; e.g.
{!!Form::select('worktype_id[]', $worktypes_list, $thing->worktypes->pluck('id'), ['class' => 'form-control'])!!}
Please or to participate in this conversation.