Default option with `->getSearchResultsUsing`
I've got a select like this:
But would like to preselect a project if its available in the route parameter, how can I do that? Tried adding
->default(1)
(1 is a project ID) but that throws An attempt was made to evaluate a closure for [Filament\Forms\Components\Select], but [$project] was unresolvable.
Also the ->preload()
doesn't seem to do anything.3 Replies
It's a select so you would neeD:
->default([1])
But it will only work on the creation and not the edit view.
Solution
Throws the same error as mentioned in my first post
->default([1])
does work on a select that loads a relationship, though.
e.g.
Also the []
in the ->default()
is only for when its a ->multiple()
, which mine isn't
Figured it out, I was missing ->options(Project::all()->pluck('name', 'id'))