getFormActions / getCreateFormAction - Need to customize the save button to add more functionality
I have a resource in which I need to change the SAVE button by a new one which saves and also adds some function that I have prepared.
How can I achieve this, please?
I have tried adding this function to the CreateResource.php:
But I do not know how to:
- Add my special function to that button (I want it to add the record to the table and do other things as well)
Any ideas, please?
I have also tried using an observer, which works fine, but then the problem is knowing how to:
- change or delete the notification typical message of "created", because my other function also gives a message and one is shown covering the other.
Tks.
Solution:Jump to solution
have you checked the Customizing the creation process in the docs? https://filamentphp.com/docs/3.x/panels/resources/creating-records#customizing-the-creation-process
also check the Lifecycle hooks in that same page.
If that doesn't cover you needs, then you need to create a Laravel Action, not a Filament action, there you will handle everything about your saving process and then maybe remove the default save button and replace it with your own, so that it invokes your action. Does this help?...
2 Replies
Solution
have you checked the Customizing the creation process in the docs? https://filamentphp.com/docs/3.x/panels/resources/creating-records#customizing-the-creation-process
also check the Lifecycle hooks in that same page.
If that doesn't cover you needs, then you need to create a Laravel Action, not a Filament action, there you will handle everything about your saving process and then maybe remove the default save button and replace it with your own, so that it invokes your action. Does this help?
Hello and thank you. Hooks is the solution.
I disabled the normal CREATE button and created an Action in the headerActions section and everything is fine. User only sees my new button and if you click it does all the functioning I have decided. Perfect.
Thank you for your time.