Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Simple tutorial on how to use ConfiForms Field Definition Rules#Showfield and it's counterpart ConfiForms Field Definition Rules#Hidefield ConfiForms Rules for Field Definitions to show and hide fields conditionally
Consider a form that has few fields like this
ConfiForms Form Definition | ||
---|---|---|
| ||
// this rule will hide the "details" field when a checkbox field "showDetails" is unchecked and will show the "details" field otherwise // this rule shows an extra field when you select an "other" option in the "options" dropdown field (and hides it otherwise) |
And the standard layout for the form
ConfiForms (FormView) Registrations Control | ||||||
---|---|---|---|---|---|---|
| ||||||
Implemented like
Image Added
Custom layout for the same form
ConfiForms (FormView) Registrations Control | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Some custom layout for the same form |
Implemented like
Image Added
Configuration
As you can see, our form has 5 fields and 2 rules. Actually there are 4 rules, as each of the 2 rules has a "reverse rule" automatically created. That works for show/hide rules very well and you do not need to create an extra reverse rule yourself.
Our 5 fields are:
- Field1 - simple text field (does not really needed here, but added to show a simplest field possible - no rules, no behaviour)
- showDetails - is a checkbox field and that manages the visibility of the other field named "details"
- details - textarea field that is shown only when the checkbox "showDetails" is checked
- options - is a dropdown field with 4 options, 4th option manages the visibility of the "userOption" field
- userOption - is a text field that is shown only when someone has selected an option with ID=4 in the "options" field
Now let's see the 2 rules that add the dynamics to our form:
Image Added
Rule 1 | Rule 2 | ||
---|---|---|---|
First rule is "bound" to field "showDetails" and tracks for changes It has a condition to check if showDetails field has value "false" We set "actionable field" as "details", as this is the field we want to manage visibility for | Second rule is "bound" to field "option" and tracks for changes It checks for "options" field to have a value 4 selected Please note that the same could be achieved by using the following filter:
(checking the label of a dropdown instead) We set "actionable field" as "userOption", as this is the field we want to manage visibility for | ||
Image Added Image Added Image Added | Image Added Image Added Image Added | ||
And we set "with reverse rule" to tell ConfiForms to create a reverse rule for us automatically. Reverse condition will be created and reverse action will be used (show → hide, and hide → show) |
You can set multiple fields in the "actionable field name" parameter, by using comma separated value list: field1,anotherfield,field3
You can do the same with 1st parameter in the ConfiForms Rules for Field Definition macro - and "bound" your rule to track changes in multiple fields (1 rule on multiple fields). Similarly to "actionable field name" parameter you can provide a comma separated list of field names
Conditions are written as filters, more on ConfiForms filters you can find here: ConfiForms Filters and ConfiForms Filters by example
Full configuration for the form in storage format
Expand | ||
---|---|---|
| ||
|
To import via Atlassian Confluence Source Editor