Adding a save button to EditPage header

So I'm trying to move the save button from the form actions to the header actions, and snatching it out of there with parent::getFormActions() and putting that into my header actions does show the button, but the button itself doesn't work, as it's no longer within the form tag.

How would I go about adding a custom action that actually saves the form currently being viewed in an edit page? It's a standard EditRecord page we're talking about here.

protected function getHeaderActions(): array
    {
        $actions = parent::getFormActions();

        return [
            Arr::first($actions)->action('save'),
            Action::make('optimized')
                ->label('Mark as Optimized')
                ->requiresConfirmation()
                ->action(function (Task $task) {
                    $task->calculateNewDeadline();
                    $this->refreshFormData([
                        'status',
                        'urgency',
                    ]);
                }),
            Arr::last($actions)
        ];
    }


This is how I grabbed the buttons from the edit form. The cancel button works fine, but that's just a link so it should. Only the save button isn't working as intended. It's the Arr::first($actions) one in that list.
Solution
For others trying to replicate adding a save button to the header:

Action::make('save')
    ->label('Save changes')
    ->action('save'),


Toss that into your getHeaderActions array, and you're off to the races. 👍
Was this page helpful?