Default option for select filter

I'm trying to set the default option in a select filter but it doesn't seem to apply.
SelectFilter::make('lead_type_profile_id')
->label('Lead Types')
->options(Filament::getTenant()->tenant->leadTypeProfiles->pluck('name', 'id'))
->default(Filament::getTenant()->tenant->leadTypeProfiles()->base()->first()->id)
->query(fn (Builder $query) => $query)
->multiple()
->preload(),
SelectFilter::make('lead_type_profile_id')
->label('Lead Types')
->options(Filament::getTenant()->tenant->leadTypeProfiles->pluck('name', 'id'))
->default(Filament::getTenant()->tenant->leadTypeProfiles()->base()->first()->id)
->query(fn (Builder $query) => $query)
->multiple()
->preload(),
Using only default() also fails to set a default selection. And I don't want to use selectablePlaceholder(false) because I do have a case where all options need to be shown in the table.
Solution:
I realized this is because I'm using multiple() so I need to return an array in default(). Here was what fixed it for me: ->default([Filament::getTenant()->tenant->leadTypeProfiles()->base()->first()->id])
Jump to solution
1 Reply
Solution
NolanN
NolanN2w ago
I realized this is because I'm using multiple() so I need to return an array in default(). Here was what fixed it for me: ->default([Filament::getTenant()->tenant->leadTypeProfiles()->base()->first()->id])
Want results from more Discord servers?
Add your server