disable wizard next button
Hello, I noticed that I cannot hide/disable the next button with the wizard nextAction. Can anyone guide me on how to disable the next button until specific conditions are met.
9 Replies
You could do so in many ways
1. by writing your condition in disable function on next action like:
->disabled(fn (Get $get) => str_starts_with('O', $get('customer_name')))
but make sure to make the corresponding field or step component ->live()
2. Or halt the next action in validation level (when button clicked) as mention in the docs
https://filamentphp.com/docs/3.x/forms/layout/wizard#preventing-the-next-step-from-being-loaded
3. You can also make to the button disabled by default and do your logic to enable it in the ->afterStateUpdated()
on the step component
Add a key for your wizard so you can target it easily ->key('my-wizard')
wizard next action button cannot be hidden. I guess it's some kind of bug. Can you please confirm?
Also, the disabled works and sets the button to disabled css but the click is not disabled and the page mount is rerun. Can you please confirm this as well? It may be a bug with wizard?
Thanks for the help. Much appreciated.
Next action button checks the disable status only and the disable status will effect by hidden status, that's mean the hidden will be considered as disabled.
And yes, the disabled function is works as expected, no extra css/js needed.
the disabled button is still sending a livewire request on click
can you confirm that
Inspect the next button it should not have
x-on:click
(alpine event listener) if it disabled
check the wizard view component
vendor/filament/forms/resources/views/components/wizard.blade.php
I have already checked it. if the button is disabled nothing happened on click.
I just notice the x-on is on the span and not the button. That's why the click is not being disabled and the wizard next step is being called. you can check the livewire call with laravel debugbar.
Does $ get work if passed in i.e.
Yes, this is how the next button works
x-on:click
placed in span tag, and should not exist if you disable the next action.
Please check vendor/filament/forms/resources/views/components/wizard.blade.php
you may have overwritten it, and if not try to update forms package.Hi, upgrading the forms package solved the issue. It seems it was bug that was fixed
disabled() now correctly removes x-on from button span
hidden() however still triggered disabled() and doesn't hide the button