© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
6 replies
ImShehryar

Multi-select select all/deselect all

Is there any better solution to select all/deselect all options then the following, needs help to refactor the toggeling
Select::make('departments')
    ->required()
    ->multiple()
    ->searchable()
    ->preload()
    ->relationship(titleAttribute: 'name')
    ->hintActions([
        Action::make('select_all')
            ->visible(fn($state) => empty($state))
            ->action(fn (Select $component) => $component->state(Department::pluck('id')->toArray())),

        Action::make('deselect_all')
            ->hidden(fn($state) => empty($state))
            ->action(function (Set $set) {
                $set('departments', null);
            }),
    ])
Select::make('departments')
    ->required()
    ->multiple()
    ->searchable()
    ->preload()
    ->relationship(titleAttribute: 'name')
    ->hintActions([
        Action::make('select_all')
            ->visible(fn($state) => empty($state))
            ->action(fn (Select $component) => $component->state(Department::pluck('id')->toArray())),

        Action::make('deselect_all')
            ->hidden(fn($state) => empty($state))
            ->action(function (Set $set) {
                $set('departments', null);
            }),
    ])
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Manually deselect all records
FilamentFFilament / ❓┊help
3y ago
multi select
FilamentFFilament / ❓┊help
3y ago
Multi-select
FilamentFFilament / ❓┊help
3y ago
Validating multi-select fields
FilamentFFilament / ❓┊help
6mo ago