Form Generator · Module-specific types

Module-specific types

Keep specialised UI next to the feature that owns it. Do not grow FormGenerator’s core switch / registry for one-off flows.

  1. Create the component under the module, e.g. pages/YourModule/formQuestions/YourQuestion/.
  2. Export a type string in local questionTypes.js (e.g. YourType: 'yourQuestionType').
  3. Map it in local questionRenderers.js:
    [YourQuestionTypes.YourType]: (_ctx, question, container, commonConfig) =>
      new YourQuestion(container, {
        data: { ...question, ...commonConfig }
      })
    
  4. Pass questionRenderers: yourModuleRenderers into new FormGenerator(…) on every page that uses that type.
  5. Return the matching questionType string from the Steps API for that flow.

Reference implementation: src/client/pages/HouseholdAccounts/formQuestions/ wired from Youth Starter Offer, Player Details, and Household Add Member.

For a full walkthrough see Creating a new question component.