-
PackagePanel builder Package Versionv3.0.0 How can we help you?I'm using Filament to build an admin panel and would like to know if it's possible to dynamically show or hide filters based on the currently selected tab in a ListResource page. Expected BehaviorWhen switching between tabs, I want certain filters to be visible only for specific tabs while others are hidden. When I switch to another tab, the previous filter is cleared. Current BehaviorFilters appear globally for all tabs, and I don't see a built-in way to conditionally show/hide them based on the active tab. Possible Solutions
Any guidance or suggestions would be greatly appreciated! Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
"When I switch to another tab, the previous filter is cleared." |
Beta Was this translation helpful? Give feedback.
-
I just solved my original issue like this: Filter::make('filters') Turns out, the key was injecting the $livewire instance and conditionally showing/hiding the filters based on the active tab! |
Beta Was this translation helpful? Give feedback.
I just solved my original issue like this:
Filter::make('filters')
->form([
CustomerSelect::make('customer_id')
->default(null)
->visible(fn($livewire) => $livewire->activeTab == 'Clienti'),
LaundryAreaSelect::make('laundry_area_id')
->visible(fn($livewire) => $livewire->activeTab != 'Clienti'),
LaundryItemSelect::make('laundry_item_ids')
->reactive()
->multiple()
])
Turns out, the key was injecting the $livewire instance and conditionally showing/hiding the filters based on the active tab!