Skip to content

Multi-step forms

A long form can be split into steps. The visitor sees one step at a time, with a progress line (“Step 2 of 3”), a list of the steps, and Back / Next buttons. The form is sent once, at the end.

Drag Step break (multi-step) from the Layout group onto the canvas. Everything below the break is the next step. The break’s label is the step’s title; leave it empty to show “Step 2”.

The first step’s title comes from a break in the very first row. Without one, the first step is called “Step 1”.

Rules (checked when you save):

  • A step break sits alone in its row.
  • Every step has at least one field. Two breaks in a row, or a break at the very end, are errors.
  • A step break has no conditions. Fields inside a step can have conditions as usual.

In the definition, a step break is a field of type step:

{"name": "about_you", "type": "step", "label": {"en": "About you", "de": "Über Sie"}}

With the frontend script (the default):

  • Next checks only the fields of the current step. Errors show next to the fields and in the summary, and the visitor stays on the step. Nothing is sent to the server.
  • Back goes back without checks. Values stay.
  • On the last step, Send sends the whole form. If the server finds an error, the form opens the step with the first error. Links in the error summary open the step of their field.
  • The Enter key always does what fits the step: Next, or Send on the last step.
  • The focus moves to the step title, so screen readers announce the new step.
  • Each change fires pimkit:form:step on the form ({form, step, steps}, step counts from 0), and pimkit_form_step in the dataLayer when that is on.

Without JavaScript, Next and Back post the form. The server checks the step and shows the page again on the right step. Values are kept in the session. One limit: uploaded files cannot be kept across steps without JavaScript, so put file fields in the last step.

pimkit_form('contact', {step: 1}) opens the second step. After a failed submit, the form opens the first step that has an error.

The plain theme’s CSS styles the stepper and the buttons. Classes:

Class What
pk-form__progress-steps The progress block (text and list)
pk-form__progress-text “Step 2 of 3”
pk-form__stepper, pk-form__stepper-item The list of steps. --done for steps before the current one, aria-current="step" on the current one
pk-form__step, pk-form__step-title One step (a fieldset) and its title (legend)
pk-form__next, pk-form__back The buttons

The bootstrap5 and tailwind themes add their own classes (keys steps, step and back).

The headless API returns the definition with the step fields in place. Split the layout at rows that hold a step field to build the steps in your own frontend.