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:
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...
Jump to solution
10 Replies
toeknee
toeknee2mo ago
IF you define the submit action on the moal it is the last one:
->submitAction(! $submitButton ? false : new HtmlString(Blade::render('<x-forms::button type="submit">Submit</x-forms::button>'))),
->submitAction(! $submitButton ? false : new HtmlString(Blade::render('<x-forms::button type="submit">Submit</x-forms::button>'))),
SKNtheKing
SKNtheKing2mo ago
I 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?
LeandroFerreira
LeandroFerreira2mo ago
getSteps to the pages, CreatePage, EditPage..
SKNtheKing
SKNtheKing2mo ago
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
SKNtheKing
SKNtheKing2mo ago
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!
SKNtheKing
SKNtheKing2mo ago
@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
LeandroFerreira
LeandroFerreira2mo ago
translate it: php artisan vendor:publish --tag=filament-forms-translations please open new topics if you have other questions
SKNtheKing
SKNtheKing2mo ago
thank you, and my bad, sorry!
Want results from more Discord servers?
Add your server