Skip to content

Dynamic Forms

Guidone edited this page Apr 22, 2023 · 5 revisions

Creating dynamic forms which changes and reacts to user input data (i.e., show or hide fields based on the value of a checkbox) it's just a matter of manipulating the structure of JSON which defines the form.

This can be done programmatically using LetsForm helpers or embedding small chunk of codes calla "transformers" in the JSON:

const form = {
  version: 1,
  transformer: `
    if (values.terms) {
      enable('really_accept_terms');
    } else {
      disable('really_accept_terms');
    }
  `,
  fields: [
    {
      "name": "terms",
      "component": "checkbox",
      "label": "Accept terms and condition?"
    },
    {
      "name": "really_accept_terms",
      "component": "checkbox",
      "label": "Really accept terms and condition?"
    }
  ]
}

setValue

tbd Modifiy a value of a field. Expection of validation fields

Clone this wiki locally