F
Filamentβ€’5w ago
Kaaiman

SelectFilter default not working

I am trying to set a default value on my SelectFilter:
SelectFilter::make('status')
->multiple()
->options(RefundStatus::class)
->default(RefundStatus::Pending),
SelectFilter::make('status')
->multiple()
->options(RefundStatus::class)
->default(RefundStatus::Pending),
This is about the same as in the docs, instead the docs use a string value.
Solution:
Make sure you use RefundStatus::Pending->value.
Jump to solution
4 Replies
toeknee
toekneeβ€’5w ago
You are using multiple so:
SelectFilter::make('status')
->multiple()
->options(RefundStatus::class)
->default([RefundStatus::Pending]),
SelectFilter::make('status')
->multiple()
->options(RefundStatus::class)
->default([RefundStatus::Pending]),
Since it is an array, as I suspect your Pending isn't an array πŸ˜‰
Solution
CodeWithDennis
CodeWithDennisβ€’5w ago
Make sure you use RefundStatus::Pending->value.
Kaaiman
KaaimanOPβ€’5w ago
@CodeWithDennis That indeed does the trick. I must say that the filament docs are sometimes not that clear in what is possible and what's not. Be thank you for your suggestion! πŸ˜„
CodeWithDennis
CodeWithDennisβ€’5w ago
Well because you use multiple it expects an array of values. ^ So like @toeknee said you should use an array, but since you also use an enum you need to grab the value of that enum.
Want results from more Discord servers?
Add your server