How to replace default actions in the Create and Edit pages?
I'm trying to build something similar to WordPress with Filament whereby a record can be published or saved as a draft.
So basically I need to override the default Create functionality.
I would like to remove the default "Create" and "Create & create another" buttons
Add add these three custom actions instead "Save Draft", "Publish", "Schedule"
and on the EditPage if
$record->isPublished()
an "Unpublish" action will be rendered instead of "Publish"6 Replies
->actions([My Actions here])
Isn't that for the list page/table? I'm referring to the Create and Edit pages
This is what I have so far. It's kind of messy.
Also I want the 'Publish' action to validate and save the form data the same way 'Create' and 'Save Changes' would
protected function getActions(): array
{
}
I beleive too for the footer actions
You would then use $this->form->getState() usually, or $this->form->validate() in native livewire so should also work
Yes that did the trick. Here's the updated code:
Not sure if I understood this. I'm guessing what I marked in a red rectangle are the Footer Actions, I want to move the Footer Actions to the Header as illustrated in the diagram. Is that possible?
I would encourage you to keep the form actions. Removing them will break the html functionality users expect by being able to submit a form with the enter key. But you can also add them to the header. And call them directly since they are registered by keeping them there.
For example in the
getHeaderActions()
method on your CreateRecord page.
And you can do the same for the edit page too. The action on that page is ‘save’
In my apps a create these as action classes so I can include them on any page and they will work.