© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•13mo ago
bottbott

Table Select Filters

On a table I have the following filters:

When I select a Network, I can only see the switches associated with this network when I refresh the page.

Is there a way to "live" update the filters?

Here is the code for the filters...

SelectFilter::make('network_id')
                    ->label('Network')
                    ->multiple()
                    ->options(fn() => ModelName::pluck('name', 'id')->map(fn($network) => ucfirst($network))->sort()->toArray())
                    ->placeholder('Select Network'),

                SelectFilter::make('switch.name')
                    ->label('Switch Name')
                    ->multiple()
                    ->searchable()
                    ->preload()
                    ->optionsLimit(1000)
                    ->options(function () use ($table) {
                        $filter = $table->getFilter('network_id');
                        $selectedNetworkIds = $filter?->getState()['values'] ?? [];

                        $query = ModelName::query();

                        if (!empty($selectedNetworkIds)) {
                            $query->whereIn('network_id', $selectedNetworkIds);
                        }

                        return $query->pluck('name', 'name')->sort();
                    })
                    ->placeholder('Select Switch Name')
                    ->query(function (Builder $query, array $state) {
                        return $state['values'] ? $query->filterBySwitchName($state['values']) : null;
                    }),
SelectFilter::make('network_id')
                    ->label('Network')
                    ->multiple()
                    ->options(fn() => ModelName::pluck('name', 'id')->map(fn($network) => ucfirst($network))->sort()->toArray())
                    ->placeholder('Select Network'),

                SelectFilter::make('switch.name')
                    ->label('Switch Name')
                    ->multiple()
                    ->searchable()
                    ->preload()
                    ->optionsLimit(1000)
                    ->options(function () use ($table) {
                        $filter = $table->getFilter('network_id');
                        $selectedNetworkIds = $filter?->getState()['values'] ?? [];

                        $query = ModelName::query();

                        if (!empty($selectedNetworkIds)) {
                            $query->whereIn('network_id', $selectedNetworkIds);
                        }

                        return $query->pluck('name', 'name')->sort();
                    })
                    ->placeholder('Select Switch Name')
                    ->query(function (Builder $query, array $state) {
                        return $state['values'] ? $query->filterBySwitchName($state['values']) : null;
                    }),
image.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Pre-select filters in table
FilamentFFilament / ❓┊help
3y ago
related select filters
FilamentFFilament / ❓┊help
17mo ago
Table filters result
FilamentFFilament / ❓┊help
10mo ago
Table filters Help
FilamentFFilament / ❓┊help
13mo ago