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.jsonfile), call the extrapolator functionmephisto.generators.generators_utils.config_validation.task_data_config.create_extrapolated_config- For a live example, you can explore the source code of run_task_dynamic.py module
- To use code insertions:
- for custom validators:
- Point
WEBAPP__GENERATOR__CUSTOM_VALIDATORSbackend env variable to the location ofcustom_validators.jsmodule (before building all webapp applications) - When using
FormComposercomponent, import validators withimport * as customValidators from "custom-validators";and pass them to yourFormComposercomponent as an argument:customValidators={customValidators} - Set this alias in your webpack config (to avoid build-time exception that
custom-validatorscannot be found):resolve: {
alias: {
...
"custom-validators": path. resolve(
process.env.WEBAPP__GENERATOR__CUSTOM_VALIDATORS
),
},
}
- Point
- for custom triggers:
- Point
WEBAPP__GENERATOR__CUSTOM_TRIGGERSbackend env variable to the location ofcustom_triggers.jsmodule (before building all webapp applications) - When using
FormComposercomponent, import triggers withimport * as customTriggers from "custom-triggers";and pass them to yourFormComposercomponent as an argument:customTriggers={customTriggers} - Set this alias in your webpack config (to avoid build-time exception that
custom-triggerscannot be found):resolve: {
alias: {
...
"custom-triggers": path. resolve(
process.env.WEBAPP__GENERATOR__CUSTOM_TRIGGERS
),
},
}
- Point
- for custom validators: