Conditional steps on wizard
Hi guys, is it possible to make conditional steps on wizard?
Right now I have this wizard on my CreateClient component:
Problem is, when I select company as a type in general step, after clicking next button it will jump to Attachments step and skips steps Company and Representative.
protected function getSteps(): array
{
return [
Forms\Components\Wizard\Step::make(__('General'))
->schema([
Forms\Components\ToggleButtons::make('type')
->label(__('Type'))
->options(ClientType::class)
->required()
->inline()
->columnSpan(4),
]),
Forms\Components\Wizard\Step::make(__('Individual'))
->schema([])
->visible(fn (Forms\Get $get) => $get('type') === 'individual'),
Forms\Components\Wizard\Step::make(__('Self-employed'))
->schema([])
->visible(fn (Forms\Get $get) => $get('type') === 'self-employed'),
Forms\Components\Wizard\Step::make(__('Company'))
->schema([])
->visible(fn (Forms\Get $get) => $get('type') === 'company'),
Forms\Components\Wizard\Step::make(__('Representative'))
->schema([])
->visible(fn (Forms\Get $get) => $get('type') === 'company'),
Forms\Components\Wizard\Step::make(__('Attachments'))
->schema([]),
Forms\Components\Wizard\Step::make(__('Address'))
->schema(Address::make()),
];
}
protected function getSteps(): array
{
return [
Forms\Components\Wizard\Step::make(__('General'))
->schema([
Forms\Components\ToggleButtons::make('type')
->label(__('Type'))
->options(ClientType::class)
->required()
->inline()
->columnSpan(4),
]),
Forms\Components\Wizard\Step::make(__('Individual'))
->schema([])
->visible(fn (Forms\Get $get) => $get('type') === 'individual'),
Forms\Components\Wizard\Step::make(__('Self-employed'))
->schema([])
->visible(fn (Forms\Get $get) => $get('type') === 'self-employed'),
Forms\Components\Wizard\Step::make(__('Company'))
->schema([])
->visible(fn (Forms\Get $get) => $get('type') === 'company'),
Forms\Components\Wizard\Step::make(__('Representative'))
->schema([])
->visible(fn (Forms\Get $get) => $get('type') === 'company'),
Forms\Components\Wizard\Step::make(__('Attachments'))
->schema([]),
Forms\Components\Wizard\Step::make(__('Address'))
->schema(Address::make()),
];
}
1 Reply
I added
->live()
to ToggleButtons::make('type') and it works just fine.