SelectFilter Add Null as an option
I have a select filter by manager:
How do I add a Null Only as another filter Option?
Currently I am using a seperate filter for Null Only
How do I combine the Null Only with the manager select?
7 Replies
Bump?
Null can't apply as a select because we need the key and label, so what you can do is make a value for example 0 on the ID to have it as 'No Manager' so
I think you are looking for
placeholder()
and selectablePlaceholder()
Do you? I think null as an option as per above allows filtering where no manager is found which is very useful in some scenarios
Oh I didn't properly read your code, because it was unreadable in the small sidebar. You are right.
This helped me move forward, thanks
THis may not be a thing but the items I'm adding should be the same type as the original items .
So for a
For another, where the id field is a string I used
User::pluck('name', 'id')->toArray()))
my added option should be numeric. + [ 0 => 'None' , -1 => Something else]
I use 0 and -1 because I added two extra selections.For another, where the id field is a string I used
'new' => "New Task"
Your answer just needed a tweak to work for me. you added the [0 => "No Manager"]
but use a string
if ($value === '0') {`. so the query never ran
Realy helpful thanks!Of course joys of mobile freehand π