Filter with recursive relationship
I have
organisations
that can be of different types. One type is school
, which has a relation to a parent organisation, with type foundation
.
If I try to add a SelectFilter
on School, filtering on parent Foundation, I get a bug in the resulting query. For easy comparing, I added another (non-recursive) filter.
Where is says and org__organisation.organisation_id = '6'
it should say and organisation_id = '6'
(or alias laravel_reserved_0
)
1. Is this indeed a bug or am I doing it wrong?
2. If I understand correctly, anything more complex than a simple relation requires a custom Tables\Filters\Filter
with a ->form()
and a ->query()
. Correct?
3. I created such a custom filter for the recursive relationship. It works beautifully, except it's not showing up in the "Active filters". How can I have it listed there?7 Replies
yes you are correct about 2
3) you need to define "indicators" (search the docs for filter indicators)
in v3 we do support nested SelectFilter relationships
Good to hear about v3! Looking forward to it.
I tried this:
It gives me the "xxx" label above the select. But no indicator is shown for that filter whatsoever. The filter works properly.
the indicator accepts a callback function, no?
There is a
->indicator()
that accepts a string, which doesn't work on custom filters.
There is also a ->indicateUsing()
that accepts a closure, which does work 🙂
This works like a charm. Looks like a regular SelectFilter now:
Thanks again @Dan Harrin !ah thats it
I am currently stuck on the same topic. I used https://filamentphp.com/tricks/dependent-select-filters for help, but I am not sure if the value of the filter option should be retrieved from the DB again? Is there a possibility to retrieve it from existing select options data?
I see SelectFilter is doing something like this:
But how to access the option from within indicateUsing?
Please open a new post.