Wizard conditionally hiding next step

Have an use case of a wizard that I need to confirm data before passing to the next step (on some steps). Is there a way to do that? I've tried to set the hidden on the action (screenshot), but it's not working: Also is there a way to know on which step we are?
No description
5 Replies
LeandroFerreira
LeandroFerreira15mo ago
you can use ->beforeValidation() ->afterValidation()
Diogo Gomes
Diogo GomesOP15mo ago
@leandro_ferreira thank you for the help. But I don't know how can I use those callbacks to prevent the user from going to the next step.
LeandroFerreira
LeandroFerreira15mo ago
maybe you can throw an exception... for example
Step::make('step1')
->schema([
TextInput::make('field1')
])
->afterValidation(function ($component): void {
$field1 = $component->getChildComponents()[0];
if ($field1->getState() == '1234') {
throw ValidationException::withMessages([
$field1->getStatePath() => 'Invalid value',
]);
}
}),
Step::make('step2')
->schema([
TextInput::make('field2')
])
Step::make('step1')
->schema([
TextInput::make('field1')
])
->afterValidation(function ($component): void {
$field1 = $component->getChildComponents()[0];
if ($field1->getState() == '1234') {
throw ValidationException::withMessages([
$field1->getStatePath() => 'Invalid value',
]);
}
}),
Step::make('step2')
->schema([
TextInput::make('field2')
])
Not sure about ->nextAction(). Maybe you can customize the ->action method
Diogo Gomes
Diogo GomesOP15mo ago
Is it possible to redirect to a particular step?
LeandroFerreira
LeandroFerreira15mo ago
Hum not sure. I've ever done this using alpine. I think you can do this. I'll try this and let you know
Want results from more Discord servers?
Add your server