rapolasgruzdys
rapolasgruzdys
FFilament
Created by rapolasgruzdys on 9/5/2023 in #❓┊help
Unable to set a default value for \Filament\Forms\Components\Select
I want to select predefined options in my Select component. Looking at the docs, if a Select component has options() set, and a default() state set - it should automatically preselect an option. Unfortunately, the example in the docs does not do anything - the default('draft') method call doesn't do anything in this piece of code:
Select::make('status')
->options([
'draft' => 'Draft',
'reviewing' => 'Reviewing',
'published' => 'Published',
])
->default('draft')
Select::make('status')
->options([
'draft' => 'Draft',
'reviewing' => 'Reviewing',
'published' => 'Published',
])
->default('draft')
I've tried setting default values via the state() method, and a bunch of others. The only working method that actually did anything was the relationship() one. But it queries eloquent for options and selected values. However, mine are static. Am I missing something obvious or doesn't this basic Select component support preselected values? Even basic HTML can do that 🤔 I was stuck with this in v2 and was hoping for a solution in v3, but nothing has changed. So my question is valid for both.
12 replies