DEV Community

Süleyman Özgür Özarpacı
Süleyman Özgür Özarpacı

Posted on • Updated on

How to create a Save Button Action in FilamentPHP

In my project, I need an action button that saves the form located below it. This is necessary because my form is too long to scroll through comfortably. As a solution, I have added a save button to the header actions.

So add this code to your resource's create or edit page actions:

Actions\Action::make('save')
    ->keyBindings(['command+s', 'ctrl+s'])
    ->icon('heroicon-o-save')
    ->action(function () {
        $this->save();
    }),
Enter fullscreen mode Exit fullscreen mode

This action uses form's save method. Also you can use keyBinding method to add some shortcuts.

Top comments (0)