F
Filament9mo ago
Jessy

wizard - hidden last step based on a radio option and save

In a 6-step Wizard component, the last step is hidden if a particular option is chosen in step 5. The problem is that step 6 is hidden, but the next button is not changed to the save button. It only changes if I take one step back and then the next. I didn't have this problem in v2. In v2 when selecting the option the step was hidden and the save button appeared. How can I hide a step and then save if a certain option is selected?
2 Replies
Jessy
JessyOP9mo ago
the buttons only update when you change the page I tried
php
->nextAction(
fn (Action $action) => $action->hidden(),
)
php
->nextAction(
fn (Action $action) => $action->hidden(),
)
but the button is stil visible
Majid Al Zariey
Majid Al Zariey4mo ago
The issue is with the button not re-rending after each step adding wire:key="{{uniqid()}}" to both nextStep and Submit div did the trick
<span wire:key="{{uniqid()}}"
x-cloak
x-on:click="
$wire.dispatchFormEvent(
'wizard::nextStep',
'{{ $statePath }}',
getStepIndex(step),
)
"
x-show="! isLastStep()"
>
{{ $getAction('next') }}
</span>

<span x-show="isLastStep()" wire:key="{{uniqid()}}">
{{ $getSubmitAction() }}
</span>
<span wire:key="{{uniqid()}}"
x-cloak
x-on:click="
$wire.dispatchFormEvent(
'wizard::nextStep',
'{{ $statePath }}',
getStepIndex(step),
)
"
x-show="! isLastStep()"
>
{{ $getAction('next') }}
</span>

<span x-show="isLastStep()" wire:key="{{uniqid()}}">
{{ $getSubmitAction() }}
</span>
You will have to override the view of course

Did you find this page helpful?