Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Simple tutorial on how to use ConfiForms Field Definition Rules#Showcontainer and it's counterpart ConfiForms Field Definition Rules#Hidecontainer ConfiForms Rules for Field Definitions to show and hide visual blocks in your forms conditionally
These rules are usually used with custom layouts, where you have your own layout defined for the form and want to show or hide blocks of fields conditionally
Consider a form that has few fields like this
ConfiForms Form Definition | ||
---|---|---|
| ||
// this rule will show the container by its "ID" when "showDetails" field is checked // this rule shows an extra field when you select an "other" option in the "options" dropdown field (and hides it otherwise) |
Custom layout for the same form
ConfiForms (FormView) Registrations Control | ||||||
---|---|---|---|---|---|---|
| ||||||
Some custom layout for the same form |
Implemented like
Using our Div container user macro | Using div macro from Content Formatting Macros for Confluence by Adaptavist |
---|---|
Image Modified | Image Modified |
Please note that Div container user macro we have has certain limitations due to the way how user macros are rendered in Confluence. If you can use other macro that can be addressed via CSS then it is advisable to use that
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:
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 "true" and we use CSS3 selector, by element id (more on CSS https://developer.mozilla.org/en-US/docs/Web/CSS)
As this is the name "mycontainer" we set to our DIV macro's ID parameter | See how it is configured here: How to show and hide fields in the form conditionally | ||
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