Based on JSON Forms React Seed App, this repo demonstrates one way to integrate JSON Forms with FigTree Evaluator in order to allow more complex form logic (such as dynamic drop-down menus and dynamic text labels).
A published demo of this repo is available at https://carlosnz.github.io/jsonforms-with-figtree-demo.
- Execute
npm ci
to install the prerequisites. If you want to have the latest released versions usenpm install
. - Execute
npm run build
to build the application. - Execute
npm start
to start the application.
Please see FigTree documentation for detailed information on how to create FigTree expressions.
The main additions here from the original JSON Forms Seed App are:
- "TextDisplay" renderer for simply displaying text-only information in the form
- "useFigTreeEvaluator" hook, which evaluates both the json schema (
schema.json
) and ui schema (uischema.json
) using FigTree. It is re-evaluated wheneverdata
(the form state data) changes. - Evaluate
visible
andenabled
parameters on each element (in UI Schema), which are compiled into JSON Forms rules. This allows the visible/enabled rules to be specified using FigTree expressions. schema.json
anduischema.json
have a number of dynamic elements using FigTree expressions.