If you need to select all options in a Multi-Select Form Component, you can achieve this easily by adding a 'hint' action.
->hintAction(Forms\Components\Actions\Action::make('select_all')
->label(__('Select all'))
->action(fn (Forms\Components\Select $component) => $component->state(array_keys($component->getOptions())))
)
The final component should look this
Forms\Components\Select::make('select_all_options')
->multiple()
->options([
'1' => 'Laravel Hive',
'2' => 'FilamentPHP',
'3' => 'Laravel',
])
->hintAction(Forms\Components\Actions\Action::make('select_all')
->label(__('Select all'))
->action(fn (Forms\Components\Select $component) => $component->state(array_keys($component->getOptions())))
)
When you view your form, you will see a 'Select all' button next to the label.