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.
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:Jump to solution
For others trying to replicate adding a save button to the header:
```php
Action::make('save')
->label('Save changes')...
7 Replies
Right in here @Dan Harrin. At least that's the current incarnation. Does it have to be a wholly custom action to work, maybe?
Ah, yep. It does. Can't just slap the action onto the OG save action, gotta be a new one.
Solution
For others trying to replicate adding a save button to the header:
Toss that into your getHeaderActions array, and you're off to the races. 👍
how would I hide the default save/cancel buttons on the form after creating them in the header?
if they aren't in the form actions array they won't get registered, iirc. You also will probably loose the ability to submit the form with 'enter' if they are removed too.
You are right. I played around a bit and found a solution.