Save form before running action
Is it possible to validate and save a form before an action it run? I want to ensure all the data is correct and stored but running a publish action.
Solution:Jump to solution
For anyone finding this here is the solution that worked for me
I removed the save buttons from the
Create
and Edit
pages and added a submitAction
to my wizard to handle saving the form.
```php...12 Replies
Call the validate method from livewire
Sorry, not sure how to do that. New to livewire and filament. Looking at some other messages they show using an action method.
I’d need to save and validate before showing the modal, or cancel if that fails.
I think should work what you showed here
the modal is opening without validation firing. and because i have not saved the model yet (it’s create form) there is no $id for the record that the modal needs.
vacancyId: '{{ $getRecord()->id }}',
- it’s null.
If I remove the form the action closure runsYeah, that's because the modal runs the
action()
when you click Submit
Is there any way to get it to work? I can run my action from the table view, but would love it in the last step of my wizard - validate, save, then open modal with the publish form
I'm not sure but I think this might require a custom action class. I think the validate + save (on the main form) needs to happen when your custom Action is being mounted.
Okay.... been playing a bit more, I could put my BraintreePayment field on the last step of the wizard by itself then validation would have already happened like normal. But I need to save the form as the custom field needs the ID
Just a thought - can you instead disable the Publish action, until the user has saved the form?
I can try that. Then it’ll appear once they save. Sounds like it should work
thank you
Solution
For anyone finding this here is the solution that worked for me
I removed the save buttons from the
Create
and Edit
pages and added a submitAction
to my wizard to handle saving the form.
When saved the user is redirected to the Edit
page for the resource. I then added a header action as below.
Nice!