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:
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()),
];
}
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.
1 Reply
Trauma Zombie
Trauma ZombieOP13mo ago
I added ->live() to ToggleButtons::make('type') and it works just fine.

Did you find this page helpful?