Reactive table filters without Livewire request

I try to customize a table filter to have a simple filter for all the basic fields and a advanced filter for basics and special cases. So far it is working, but every time I toggle between basic and advanced a request is triggered. What would be the approach to do this in the frontend only without the request?
protected function getTableFilters(): array
{
return [
Filter::make('my_filtere')
->form([
Forms\Components\Toggle::make('advanced_filter')
->default(false)
->dehydrated(false),
Forms\Components\Select::make('country_id')
->label('Land')
->options(Country::all()->pluck('full_name', 'id')->toArray()),
Forms\Components\Select::make('region_id')
->label('Region')
->options(Region::all()->pluck('full_name', 'id')->toArray()),
Forms\Components\Select::make('subregion_id')
->hidden(fn (Closure $get) => $get('advanced_filter') == false) //has to be in the same form !!!
->label('Subregion')
->options(Subregion::all()->pluck('full_name', 'id')->toArray()),
])
];
}
protected function getTableFilters(): array
{
return [
Filter::make('my_filtere')
->form([
Forms\Components\Toggle::make('advanced_filter')
->default(false)
->dehydrated(false),
Forms\Components\Select::make('country_id')
->label('Land')
->options(Country::all()->pluck('full_name', 'id')->toArray()),
Forms\Components\Select::make('region_id')
->label('Region')
->options(Region::all()->pluck('full_name', 'id')->toArray()),
Forms\Components\Select::make('subregion_id')
->hidden(fn (Closure $get) => $get('advanced_filter') == false) //has to be in the same form !!!
->label('Subregion')
->options(Subregion::all()->pluck('full_name', 'id')->toArray()),
])
];
}
3 Replies
Maxxx22
Maxxx22OP2y ago
GitHub
filament/08-advanced.md at 3.x · filamentphp/filament
Admin panel, form builder and table builder for Laravel. Built with the TALL stack. Designed for humans. - filament/08-advanced.md at 3.x · filamentphp/filament
Dennis Koch
Dennis Koch2y ago
What would be the approach to do this in the frontend only without the request?
It's not possible. That's in the nature of Livewire
Maxxx22
Maxxx22OP2y ago
Ok, thanks anyway
Want results from more Discord servers?
Add your server