Adding an Action to a Form Section?
Have been trying to add an action to form sections but have been unsuccessful, any solutions?
protected function getFormSchema(): array
{
return ([
Section::make('Modify Balance')
->schema([
TextInput::make('bal_subscriberId')->label('Subscriber ID'),
TextInput::make('bal_amount')->label('Amount'),
Checkbox::make('bal_setBalance')->label('Set Balance'),
TextArea::make('bal_description')->label('Description'),
]),
Action::make('updateBalance')
->label('Update Balance')
->action('updateBalance'),
Section::make('Modify Package Limits')
->schema([
TextInput::make('limit_packageId')->label('Package ID'),
TextInput::make('limit_dataBytes')->label('Data Bytes (in bytes)'),
TextInput::make('limit_moCalls')->label('MO Calls (in seconds)'),
TextInput::make('limit_mtCalls')->label('MT Calls (in seconds)'),
TextInput::make('limit_moSms')->label('MO SMS'),
TextInput::make('limit_mtSms')->label('MT SMS'),
TextArea::make('limit_comment')->label('Comment'),
]),
Action::make('modifyPackageLimits')
->label('Modify Package Limits')
->action('modifyPackageLimits')
Solution:Jump to solution
Run
composer about
and see what filament version you are on. You may be on a version before that was introduced.4 Replies
Inside of a form actions have to be wrapped inside an Actions component. https://filamentphp.com/docs/3.x/forms/actions#adding-anonymous-actions-to-a-form-without-attaching-them-to-a-component
I saw that, but I was not able to get \Components\Actions to work
Class "Filament\Forms\Components\Actions" not found
use Filament\Forms\Components\Actions;
use Filament\Forms\Components\Actions\Action;
Section::make('Modify Balance')
->schema([
TextInput::make('bal_subscriberId')->label('Subscriber ID'),
TextInput::make('bal_amount')->label('Amount'),
Checkbox::make('bal_setBalance')->label('Set Balance'),
TextArea::make('bal_description')->label('Description'),
]),
Actions::make([
Action::make('updateBalance')
->label('Update Balance')
->action('updateBalance')
]),
Solution
Run
composer about
and see what filament version you are on. You may be on a version before that was introduced.ugh, I literally just installed filament for the first time last week, how did i install 2.17.55..
worked few some bugs with the newly updated methods, all good now!
Thank you!