Toggle menu

Conditional Fields

The condition function of this field is evaluated server-side as the form page is being rendered. It can access the values of fields in your form, or helper variables generated in default functions, that appear before the conditional field (either on previous pages, or fields that are above the conditional layout on the current page).

If the condition is not met, the fields in the layout will not be present on the page and so cannot be interacted with in any way. This differs from fields that have simply been hidden. Hidden fields are still present on the page (but invisible) and so they can be interacted with.

There will always be a field value for the container field itself, available using helper.getFieldValue. This is contains the string "true" if the field has been rendered, "false" if not.

Note that the conditional function is evaluated once, when the page is rendered. The result of this evaluation is used when performing server-side validation, action scripts and button control processing.

The 'show' property affects when the function is evaluated. This property can be used to prevent the function being evaluated and anything output when the form s being rendered normally or in summary (email) mode.

There's an example of the conditional field in the Conditional Layout Fields article.

Properties

LabelDescriptionType Name
LabelThe label for the container, only used for read only viewsLABEL
ShowDetermines when the container conditional function should be evaluated and any contained fields output.

By default, the conditional function will always be evaluated and the contained fields will be output if the function returns true. Change this setting if the conditional function should only be evaluated in read only mode (eg. in emails/pdfs) or standard mode (eg. when the form is rendered for input).

The following options are available:

Always - the conditional function will always be evaluated.
Form - the HTML will only be output when the page HTML is being rendered on the site (in 'standard' mode).
Summary (Email) - the HTML will only be output when the page HTML is rendered in read only mode, without controls e.g. in emails.
SHOW
Condition FunctionA JavaScript function that is executed server-side to determine if the fields within the container should be displayed.

This function uses the following format:

function (helper) {
    var showFields;
    showFields = true;
    return showFields;
}

It should return true to display the fields. The values of other stored field values can be accessed via the helper library supplied as the first argument.

Note that this function is only evaluated if the conditions for showing the container are met. For example if the container 'show' property is only defined for the Summary (email) output this function will not be executed when rendering the form normally
CONDFUNCTION
DefaultThis property sets the default behaviour if no conditional function is defined. Normally a conditional function is defined and this determines when any contained fields will be outputDEFAULT
DocumentationAdd documentation to your field to help explain any complex functionality to future users. You might include information on what the field does and how it relates to other fields on the form. Notes added here are only ever visible in the Forms Designer, they can be searched for, viewed and downloaded from the action panel. See Common Field Properties for an exampleDOCUMENTATION
Last modified on 11 November 2022

Share this page

Facebook icon Twitter icon email icon

Print

print icon