SelectFilter hidden()
So I have this SelectFilter that I want hidden based on $activeTab that is set by getTabs(). I have What I am finding odd is that while ray() is showing a matching activeTab value, its not hidding on first ocurrence when switching to one of the tabs that it should be hidden on even though ray shows a value that would be true. The in_array() is returning the proper true/false too. Suggestions? I had this issue with toggleable columns at one point and i started doing a $this->resetPage() when a tab was changed and that solved it, but this appears to fire before the filter hidden() logic is ran. Also, the hidden() method is seeing the right values, so thats not it.
Solution:Jump to solution
@archilex this is working great. thanks! ```php
->hidden(function () {
$tabsToHideFilter = ['active', 'inactive', 'draft'];
$shouldHideFilter = in_array($this->activeTab, $tabsToHideFilter);
...
10 Replies
@Mark Chaney Hi. It's because the form is being cached and it's pulling the cached form when you click the tab. You see the caching in the
getTableFiltersForm
method in HasFilters
. One option would be to unset the cachedForm after clicking on the tab: unset($this->cachedForms['tableFiltersForm'])
to force it to re-render the form.@archilex awesome. thanks! While I have your attention, how about unsetting the filter on certain tabs? 😛
once we are on the panel and out of alpha, I really just need to use your plugin
There's a
removeTableFilters()
and removeTableFilter()
method you can probably tap into depending on what you need.
Advanced Tables v3 (formerly #filter-sets) is out now. yay!!! I'm waiting for the plugin to update on Filament's site to start promoting, change discord name, etc.pff, didn't go for Table Builder Plus? 😛
haha...I like that Advanced starts with an "A"! Pretty much the only reason. I didn't want to go further down the alphabet
Solution
@archilex this is working great. thanks!
had to move cache unset to hook. wasnt working reliably from filter. not a huge fan, but not a big deal. Didnt really want to unset the cache unless it was needed to do, but now it happens on every tab change. oh well
Can you do a conditional?
@kennethsese that method is on my FilterTableTabs trait
Or...