Form Generator

FormGenerator is the client-side orchestrator for multi-step and multi-section forms. It renders questions from declarative JSON (usually from a backend Steps API), handles navigation, validation, dependent visibility, and answer collection.

Source: src/client/components/FormGenerator/ ยท Shared types live in core; module-owned types (e.g. Household) register via questionRenderers.

How it works

  1. Instantiate โ€” new FormGenerator(container, config) merges core + page questionRenderers, then renders into the container.
  2. Render steps โ€” One step wrapper per totalSteps. Each question mounts into .js-form-generator-question-{id}.
  3. Look up the renderer โ€” question.questionType selects a factory from the registry. The instance is stored on question.ref.
  4. Collect answers โ€” On change, answers merge into formGenerator.answers[step][questionId].
  5. Navigate & validate โ€” Next runs stepValidator(), then advances. On the last step, Next becomes Submit.
  6. Dependent questions โ€” Radio/checkbox options can list dependentQuestion: [ids]. Selection shows/hides those questions and clears answers for hidden ones.

Continue reading

Browse by topic โ€” playgrounds live under their own section.

Playgrounds

Interactive previews with editable question JSON โ€” including General, Household, and Search & Finder components.