Conditional Fields
A conditional field (Field "A") is only displayed in the form when the user has selected a specific option for another field (Field "B"). So there are always at least two fields involved. A resticting field (field A in our "scenario") and the conditional field (field B in our "scenario")
Which field types can be used as resticting fields?
Selects, radios, checkbox groups and checkboxes, can be used as restricting fields which trigger the visibilty of conditional fields.
Which field types can be used as conditional fields?
The conditional fields can be of any field type except buttons.
Setting up a conditional field
- Create at least one field of type select, radio, checkbox group or checkbox, which you will then use as restricting field.
- Create a second field, which is the field which you want to make conditional.
- Save the second field
- Click inside the input of the "Conditional Field" option of the second field. You will see all options which you created for the first field, in this dropdown list.
- Select the option, that will trigger the display of the second field.
- Use Ctrl for multi selection.
- Save the second field.
The following pictures may clarify the process.
You can select more than one condition in the "Conditional field" option list. These conditions will always be considered or conditions. If you want to define multiple conditions as and conditions you have to use nested conditional fields, as described in the next paragraph.
Depth of conditions
It is possible to use a conditional field as restring field in order to make a third field conditional. So field A controls the visibility of field B which controls the visibility of field C. There are no limits in depth.
Endless loops ara avoided
You will only find those option in the "Conditional Field" which do not directly or indirectly affect the visibility of a given field. Thus loops like field A hides field B and field B hides field A are avoided.
Some consequences of introducing conditional fields
The introduction of conditional fields has created direct interactions between different form fields for the first time. As a consequence some actions in the configuration of one field may have effects on other fields which are in conflict with the interaction created between fields. Therefore some actions are no longer possible (without removing the interactions between fields first). Visforms will inform you with error messages. The following actions are restricted:
- The Field type of a field, that is used as regulating field (selected in the "Conditional Field" option of another field), cannot be changed
- Regulating fields cannot be deleted
- Regulating fields, cannot be unpublished
- If you copy a regulating field (batch copy form, batch copy field or use "Save as Copy" button in the field configuration), all conditions which are not longer valid in the new environment are removed from the copied field.
- When you create a new field or change the field type of an existing field, the "Conditional fields" option of this field will be empty until you save the field for the first time.
- The "name" of a regulating field must not be changed.
- Options which are used to regulate the display of other fields must not contain a colon!