Hiding Create form buttons untill the last step of a Wizard
Hello everyone, im trying to use a wizard to create an item in a resource, but i would like the form buttons like create and create another to only be visible when on the last step of the wizard. I've tried a lot of solutions but none of them seem to work. Anyone got an idea on how to do it?
Thank you in advance!!
Solution:Jump to solution
Basically, if you need to hide the form buttons, you can use the HasWizard trait (https://filamentphp.com/docs/3.x/panels/resources/creating-records#using-a-wizard props @Leandro Ferreira) and then create the getSteps function in your record handler class (Create/EditPage). This function returns the steps your wizard has to the form and uses the handleRecordCreation/Update method, if you have overriden it, it uses your logic, or else it uses the default, to display a button on the last step of...
10 Replies
IF you define the submit action on the moal it is the last one:
if you are using a resource, you should use the
HasWizard
trait
https://filamentphp.com/docs/3.x/panels/resources/creating-records#using-a-wizardI am defining the wizard on the form function on the main resource, with that trait how can i check how many steps it has? or do i have to create the getSteps function on the createresouce class?
getSteps
to the pages, CreatePage, EditPage..Well thats so much easier, i was handling all the data with If clauses to check if it was even there when saving, it just saves so many lines of code. I thought of using the steps function but i would never have noticed I was missing that trait, thank you so much! I marked your answer as solution but im going to write a small text explaining the whole process and mark that so its easier to understand when searching!
Solution
Basically, if you need to hide the form buttons, you can use the HasWizard trait (https://filamentphp.com/docs/3.x/panels/resources/creating-records#using-a-wizard props @Leandro Ferreira) and then create the getSteps function in your record handler class (Create/EditPage). This function returns the steps your wizard has to the form and uses the handleRecordCreation/Update method, if you have overriden it, it uses your logic, or else it uses the default, to display a button on the last step of the wizard to create or save the changes you made to the record. In the end, you don't need to do anything to hide the buttons, as i thought, you just need to let filament handle the form for you with the getSteps function!
@Leandro Ferreira im sorry to bother again, but is there any way i can change the next button text to "seguinte" on the wizard when implementing it with the getSteps method? I ve looked into the docs but found nothing
translate it:
php artisan vendor:publish --tag=filament-forms-translations
please open new topics if you have other questionsthank you, and my bad, sorry!