Who this is for. The front-end developer building or checking a form's conditional fields in the browser. What the rules mean is on Conditional logic; this page is the script's contract.
The file and when it starts
Served by every site at /assets/forms/js-forms-conditionals.js. It works on every .coredna-js-form container, on both form models: a page-per-step layout wraps its form in the container for this script's sake (the wiring).
It starts only on the page's DOMContentLoaded event. Load it with a plain or a defer script tag in the page, not with async or from another script, so it starts before that event. (js-forms.js starts either way; this one does not.)
The data the layout prints
For each container, the script reads the form id from input[name="_formId"] and the rules from window['formConditionals' + formId], which the layout prints from the form's active revision (the snippet).
- No variable: "Conditionals not found for form ID: n" in the console, and the form keeps every field visible. Print an empty list for a form without rules.
- Every container needs its
_formIdinput, so the script can set this container up, and the ones after it on the page.
The variable is a list of conditionals, each with conditions (all must match) and actions. Each condition and action has an entity and settings with field, state and, where it applies, value:
| Entity | field | state |
|---|---|---|
Forms\Entities\ConditionValue | Element id | filled, empty, checked, unchecked |
Forms\Entities\ConditionString | Element id | equal, not_equal, contains, not_contains |
Forms\Entities\ConditionNumeric | Element id | less, greater, less_equal, greater_equal |
Forms\Entities\ConditionDate | Element id | equal, not_equal, before_date, after_date |
Forms\Entities\ConditionMatch | Element id | regex, not_regex |
Forms\Entities\ActionFieldVisibility | Element id | show, hide |
Forms\Entities\ActionGroupVisibility | Group's element id | show, hide |
Forms\Entities\ActionStepVisibility | The step's name | show, hide |
Forms\Entities\ActionRequirements | Element id | required, not_required |
Forms\Entities\ActionUpdate | Element id | None; value is the new value |
Forms\Entities\ActionClass | Element id | add_class, remove_class; value holds the classes, separated by spaces |
The markup it looks for
| Target | Found by | What changes |
|---|---|---|
| A field in a condition | [data-id="element id"]; every input with that id, so a radio group or checkbox list is read as one | Nothing; its value is read |
| A field to show or hide | The closest .base-element-block, or .static-element-block, around [data-id] | Its display |
| A group | fieldset.element-group-block[data-id="…"] | Its display |
| A step | .form-step[data-step-name="…"] | Its display, and data-skipped="true" while hidden, which js-forms.js steps over |
| A static element's text, for Update | .element-text inside it | Its text |
| Classes, for Class | The .base-element-block.input-element-block around the field, or the static block | Its classes |
The platform's own form markup carries all of these. A layout that prints its own fields has to keep data-id, the block classes and data-step-name; every element needs an id.