With the Conditional Fields macro, you can specify different conditions that allow you to customize the form. This is useful for creating dynamic forms that react to user input.
Hide and Show Conditions
These two conditions allow you to dynamically hide or show some fields within a form. In this example, we want to collect information about the user regarding a training day that is pending. The organizer needs to know if there are some dietary restrictions, if there are, then Forms for Confluence needs to show the dietary preference.
- Create your form using the Forms for Confluence macro.
- Let's add the dietary restrictions radio button group and the dietary preferences checkbox group.
- We only want to show the preferences if the choice for the restrictions is "yes".
Let's add a Conditional Fields Macro.
Only fields that are visible are submitted. Conditional Fields work with all type of fields, except the Hidden field Macro since it is always hidden.
Under Field, we choose Restrictions. If the value is "No" then we choose to "Hide" the dietary preferences.
Field: the macro name where the decision takes place.
Field value: the specific value to cause the trigger.
Action: the result is to show or hide a macro.
If the action is "Show" then the target macro will remain hidden as its default state. It is possible to assign both the "Hide" and "Show" action to the same target macro, however since these are conflicting actions only the last triggered condition will be actioned.
Target Field: the macro to be shown or hidden.
As a result, when choosing "No" the preference field will hide, and if we choose anything else, it will show, in this case,
the "Yes" option:
The Conditional Field macro does not support the use of single or double quotes (
' or ") in the Field Value input box or in field names selected for the Field or Target parameter for conditions.
Go to Page Condition
The Go to page and Finish conditions can be used only within a form with multiple pages. These two conditions don't appear if the form doesn't contain additional pages.
The Go to page condition skips to a particular form page if the condition is matched. This is useful when the user does not need to fill the details of particular pages during the process. In the following example we want the user to skip the 'Company Details' section if he's a freelancer:
Having the following condition:
If a user is a freelance worker, he doesn't need to fill the details of the 'Company Details' section.
When the user replies yes to the question 'Are you a freelance worker' and click the next button to move to the next section, then the user will jump directly to 'Event Details' page without the need to fill 'Company Details' page.
The Finish condition permits the submission of data without the need to complete all the pages of a form. This is useful if users do not need to go through the whole process of a form submission. In the following example, we want the user to don't continue to fill all the pages and submit the data when he's not going to attend the event:
Having the following condition:
The user doesn't need to continue until the end of the form process if the user is not attending the event, but he/she can just submit the details collected so far.
When the user replies yes to the question 'Are you going to attend the event required', the Next button is transformed into a Submit button and by clicking it, all the details get submitted.