ErlangFormDocs v1.0.0
Integration guides

Wizard

Split a form into steps and validate forward navigation.

1. Identity2. Contact

Identity

Complete this step, then choose Next.

wizard filters the root fields visible on each step while keeping all values in one form. Enter a name of at least two characters, choose Next, then enter an email and finish. Back navigation keeps the current values.

Usage

Use your form instance from useForm. See the initial setup.

example.tsx
const schema = z.object({ name: z.string(), email: z.email() });

<ErlForm
  form={form}
  schema={schema}
  wizard={{
    steps: [
      { id: "identity", title: "Identity", fields: ["name"] },
      { id: "contact", title: "Contact", fields: ["email"] },
    ],
    validateStep: (step, values) => step === 0
      ? values.name.length >= 2
      : z.email().safeParse(values.email).success,
  }}
/>

Options

OptionBehavior
stepsNonempty list with unique id, title, optional description, and fields
previousLabelBack button; defaults to Previous
nextLabelForward button; defaults to Next
firstStepLabelForward label on the first step
lastStepLabelPresent in the type but not used by the 1.0.0 renderer
validateStepBoolean or Promise boolean before moving forward
onStepChangeNew zero-based step index

fields accepts root field names, not nested paths. Include an object's root name to show all of its children on a step. Keep the step list stable while the form is in use.

Next does not automatically validate the Zod schema, and the wizard does not create a submit button or prevent Enter from submitting the HTML form. The demo guards submission until the last step and displays a message when validation blocks Next. Always validate the complete schema before saving.

Moving backward does not invoke validateStep. Handle asynchronous callback failures in your application; Next has no built-in pending state.

On this page