Skip to main content

Embed FormComposer into custom application

A few tips if you wish to embed FormComposer in your custom application:

  • To extrapolate form config (and generate the task_data.json file), call the extrapolator function mephisto.generators.form_composer.configs_validation.extrapolated_config.create_extrapolated_config
  • To use code insertions:
    • for custom validators:
      • Point WEBAPP__FORM_COMPOSER__CUSTOM_VALIDATORS backend env variable to the location of custom_validators.js module (before building all webapp applications)
      • When using FormComposer component, import validators with import * as customValidators from "custom-validators"; and pass them to your FormComposer component as an argument: customValidators={customValidators}
      • Set this alias in your webpack config (to avoid build-time exception that custom-validators cannot be found):
        resolve: {
        alias: {
        ...
        "custom-validators": path. resolve(
        process.env.WEBAPP__FORM_COMPOSER__CUSTOM_VALIDATORS
        ),
        },
        }
    • for custom triggers:
      • Point WEBAPP__FORM_COMPOSER__CUSTOM_TRIGGERS backend env variable to the location of custom_triggers.js module (before building all webapp applications)
      • When using FormComposer component, import triggers with import * as customTriggers from "custom-triggers"; and pass them to your FormComposer component as an argument: customTriggers={customTriggers}
      • Set this alias in your webpack config (to avoid build-time exception that custom-triggers cannot be found):
        resolve: {
        alias: {
        ...
        "custom-triggers": path. resolve(
        process.env.WEBAPP__FORM_COMPOSER__CUSTOM_TRIGGERS
        ),
        },
        }