F
Filamentβ€’7mo ago
GavTheDev

Wizard: different steps based on value in step 1

I'm trying to create a wizard where the first step is choosing an option, and based on that option the next step shows the form for that type. Is there an easy way to achieve that? One option is to just set steps visible/hidden, but is that the best way?
4 Replies
Davide Cariola
Davide Cariolaβ€’6mo ago
Have you solved it?
GavTheDev
GavTheDevOPβ€’6mo ago
No πŸ˜• But would love to hear it if you have!
LeandroFerreira
LeandroFerreiraβ€’6mo ago
You can use visible/hidden in the next step..
Wizard::make()
->steps([
Wizard\Step::make('first')
->schema([
Select::make('select')
->options([
'1' => 'Option 1',
'2' => 'Option 2',
])
->live()
]),
Wizard\Step::make('second')
->schema([

Group::make([
TextInput::make('option1'),
])
->visible(fn (Get $get): bool => $get('select') === '1'),

Group::make([
TextInput::make('option2'),
])
->visible(fn (Get $get): bool => $get('select') === '2')
]),
])
Wizard::make()
->steps([
Wizard\Step::make('first')
->schema([
Select::make('select')
->options([
'1' => 'Option 1',
'2' => 'Option 2',
])
->live()
]),
Wizard\Step::make('second')
->schema([

Group::make([
TextInput::make('option1'),
])
->visible(fn (Get $get): bool => $get('select') === '1'),

Group::make([
TextInput::make('option2'),
])
->visible(fn (Get $get): bool => $get('select') === '2')
]),
])
Davide Cariola
Davide Cariolaβ€’6mo ago
Hi @GavTheDev , yes, In the end, I decided to use visible/hidden
Want results from more Discord servers?
Add your server