Advanced Conditions
Advanced Conditions allows form builders to use JavaScript or JSON custom code to conditionally show or hide fields when more complex conditions are required.
This is useful when the conditional relies on a sub-function within the JavaScript code that compares different values. It gives form builders the flexibility to write complex conditions tailored to their needs.
Available Variables:
- form: The complete form JSON object.
- submission: The complete submission object.
- data: The complete submission data object.
- row: Contextual "row" data, used within DataGrid, EditGrid, and Container components.
- component: The current component JSON.
- instance: The current component instance.
- value: The current value of the component.
- moment: The moment.js library for date manipulation.
- _: An instance of Lodash.
- utils: An instance of the FormioUtils object.
- util: An alias for "utils".
Example Usage:
show = (data.income < 45000) & (data.maritalStatus == 'single' || data.maritalStatus == 'widowed');
In this example, the field will be shown when the Currency field has a value less than $45,000, and when the maritalStatus field has the value 'single' or 'widowed'.
Important Notes:
- Use the Property Name when referencing components inside your code. You can find this in the API Tab of the component settings.
- When referencing values, always use the Value and not the Label within JavaScript code. Component values can be found in the Data Tab of the component settings. This is crucial for components like Radio, Select, and Select Box.