Filter gets applied automatically?
Hey again - sorry if my questions are a bit noob-like, I just try to get filament figured out... π
This time I have a weird behaviour. I want to show some articles in my table. For that my table actually uses a morphed-model which has an "article"-relationship.
What I want: Show only articles where article.is_locked = 0 and make articles with article.is_locked = 1 only visible if a filter is active.
I got so far to build a filter like this:
But this filter seems to get applied automatically, so right now I only see locked articles even tho the filter is not active.
My two questions here are: Is this normal an intended? And secondly - I am sure I am missing something here, but I need help figuring out what exactly.
Thanks. π
6 Replies
$data
and check for the value, and apply the filter only if the value in the data is true
So like this?
And does this cover the preamptive filtering (get me all data where article.is_locked = 0) aswell?
At first you will get everything (lock == 0 or 1) if you didn't change the default model query.. If toggle then base on your query you should see the filter..
default false?
@husky110 remove the
.
from the filter name, it seems like that is causing it to be always active
Tables\Filters\Filter::make('is_locked')
And how do I change the default query? Didn't find it in the docs yesterday...
Yep - Thank you. That removed the "always active"-part. π
Okay - My whole approach to this was wrong... After some more reading I was able to achieve what I wanted by using a TernaryFilter. I think that thing was designed to that specific use-case, but when you are new to this whole approach (never worked with a frontend-stack before) it just happens that the concepts are not clear from the get go.
Thank you all for your time and efforts tho. π