Skip to content

Wizard

A wizard splits the create form into steps. When editing and on the detail page, the steps are shown as sections one below the other, so every field is reachable at once.

use Anvil\Schema\Layout\Step;
use Anvil\Schema\Layout\Wizard;
Wizard::make()->steps([
Step::make('Deal')->columns(2)->schema([
TextInput::make('title')->required()->maxLength(150)->columnSpanFull(),
BelongsTo::make('contact_id')->label('Contact')->relationship(ContactModel::class, 'name')->searchable(),
NumberInput::make('amount')->currency('EUR')->min(0),
]),
Step::make('Line items')->schema([
Repeater::make('line_items')->schema([...])->maxItems(10),
]),
Step::make('Description')->description('Shown to the customer.')->schema([
MarkdownEditor::make('description')->rows(6),
]),
]),
Method Effect
Wizard::make()->steps([Step, ...]) the steps, in this order
Step::make('Heading') heading of the step
icon(), columns(), schema() as for a Tab
description('…') shown when the steps are rendered as sections
hiddenOn(...) on the wizard or single steps
  • A progress line shows the current step (“Step 2 of 3”).
  • Next first checks the inputs of the current step in the browser (required, length, type); Back goes back without checks. Enter moves to the next step instead of submitting early.
  • The save button appears on the last step.
  • The checks in the browser are a convenience only. The server validates the whole form on saving, like every other form, and shows the step of the first error.

The steps are rendered as sections with their heading and description, one below the other. A wizard therefore suits records that are created once in a guided way and later edited freely.

Use one wizard per form, at the top level.