© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
5 replies
Blackpig

Add an option to Checkboxlist via an Action

I'm trying to recreate similar behaviour to the
->createOptionForm()
->createOptionForm()
of the Form\Select component https://filamentphp.com/docs/3.x/forms/fields/select#creating-a-new-option-in-a-modal but on a CheckboxList.

I was hoping I could utilise either the
->helpertext()
->helpertext()
or
->hint()
->hint()
methods and trigger an Action.

It renders ok - but the Action doesn't trigger the modal/form - is this possible or do I need top change my approach?

CheckboxList::make('roles')
  ->helperText(function(): Action {
    return Action::make('createRole')
             ->label('Add a new role')
              ->link()
              ->form([
                      TextInput::make('title')
                        ->required(),
                      TextInput::make('hourly_rate')
                        ->label('Hourly Rate')
                        ->required()
                        ->type('number')
                        ->inputMode('decimal')
                        ->default('25.00'),
                       ])
              ->action(function (array $data): void {
                $newRole = new StaffRole;
                $newRole->title = $data['title'];
                $newRole->hourly_rate = $data['hourly_rate'];
                $newRole->save();
              });
   })
    //->url(fn() => route('filament.admin.resources.staff-roles.create'))
    ->required()
    ->relationship(titleAttribute: 'title')
    ->columns(4)
]);
CheckboxList::make('roles')
  ->helperText(function(): Action {
    return Action::make('createRole')
             ->label('Add a new role')
              ->link()
              ->form([
                      TextInput::make('title')
                        ->required(),
                      TextInput::make('hourly_rate')
                        ->label('Hourly Rate')
                        ->required()
                        ->type('number')
                        ->inputMode('decimal')
                        ->default('25.00'),
                       ])
              ->action(function (array $data): void {
                $newRole = new StaffRole;
                $newRole->title = $data['title'];
                $newRole->hourly_rate = $data['hourly_rate'];
                $newRole->save();
              });
   })
    //->url(fn() => route('filament.admin.resources.staff-roles.create'))
    ->required()
    ->relationship(titleAttribute: 'title')
    ->columns(4)
]);
Select - Form Builder - Filament
Solution
Im not sure that
->helperText()
->helperText()
accepts an action by default. But maybe you could use
->hintAction()
->hintAction()
instead? 🤔
Jump to solution
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

CheckboxList description per option?
FilamentFFilament / ❓┊help
3y ago
How to add tooltip to CheckboxList component
FilamentFFilament / ❓┊help
2y ago
SelectFilter Add Null as an option
FilamentFFilament / ❓┊help
9mo ago
Is it possible to add an Action to an Infolist Section header?
FilamentFFilament / ❓┊help
3y ago