DEV Community

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

Posted on • Edited on

3

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay