F
Filament8mo ago
Vp

select 'default' not working in filter action/forms

I am trying to filter dashboard widget using filter action/forms, I provide months options and try to set default to current month. Below is how I did
FilterAction::make()
->form([
Forms\Components\Select::make('month')
->options([
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
...
])
->default(now()->month)
->selectablePlaceholder(false),
]),
FilterAction::make()
->form([
Forms\Components\Select::make('month')
->options([
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
...
])
->default(now()->month)
->selectablePlaceholder(false),
]),
When page refresh, the select options always pointing to first item only instead of default
Solution:
I think this is my chrome bug for that specific project.. I've restart the system and now it always pointing to 'October' 🤣 I check in firefox and it's working fine.. so I think there is no error...
Jump to solution
10 Replies
LeandroFerreira
LeandroFerreira8mo ago
When page refreshes..? Isn't it setting 4 to the Select as default?
Vp
VpOP8mo ago
No, always set to 1 (January) in default, when page refresh means when I change options to 'Jan', 'Feb' etc it display correct data but after refresh it set to 1 (Jan) only
LeandroFerreira
LeandroFerreira8mo ago
Weird.. Filament version?
Vp
VpOP8mo ago
Now v3.2.50 let me try to update and check again
Vp
VpOP8mo ago
Updated to v3.2.63 and still the same
Vp
VpOP8mo ago
I've created a new project and the same code is working fine.. what should be the error in my existing one.....
LeandroFerreira
LeandroFerreira8mo ago
hum ok
Solution
Vp
Vp8mo ago
I think this is my chrome bug for that specific project.. I've restart the system and now it always pointing to 'October' 🤣 I check in firefox and it's working fine.. so I think there is no error
Vp
VpOP8mo ago
Bumping this again because there is weird things happening again.. dd(now()->month) inside dashboard gives me 4 but dd($this->filters['month']); inside widgets getStats() gives me "3" so It filter "March" data only, not April (current month)
prnl.
prnl.8mo ago
I just ran into the same problem, Filament keeps track of the latest selected value inside a session/cookie called Dashboard_filters, after a refresh it will use that value to set the default. Try removing your cookies and see what default value is used, most likely it will use April 🤞
Want results from more Discord servers?
Add your server