The if
element toggles the visibility of a group of controls
dynamically, based on a predefined condition.
Fields
Field | Description |
---|---|
id |
Identifies the control when it is referenced in data-binding queries, reports, and workflow scripts. |
Traits
Trait | Description |
---|---|
declarations |
A collection of zero or more variable declarations (let elements) that can be referenced in solution-wide query expressions. |
validation |
A collection of zero or more validation rules (validator elements) that evaluate user input in the control at
runtime, and prevent the user from submitting the form if the |
content | Zero or more miscellaneous controls that are displayed in the form only if
the cond property evaluates to true.
|
Remarks
If the if
has an id, you can reference the condition elsewhere in the form, and
the property gets submitted to the server with the form, so it is also available as a
reference in workflow
scripts.
... <checkbox id="checkboxBroo" text="Know what I mean? Know what I mean?"/> <if id="ifAoo" cond='{checkboxBroo.checked}'> <textview id="textviewSwoo" text="Nudge, nudge. Wink, wink. Say no more!"/> </if> <if cond='{ifAoo.cond == false
}'> <textview text="I'm afraid I don't quite follow you."/> </if> ...
Regardless of having an id
, and even if the
conditional child controls of the if
are hidden (because the
cond
expression evaluates to false
or
NULL
), the submitted properties of all the child controls with an
id
are still submitted to the server with the form, and they are also
data-bindable, just as if the child controls were
displayed.
... <checkbox id="checkboxBroo" text="Know what I mean? Know what I mean?"/> <if id="ifAoo" cond='{checkboxBroo.checked}'> <textview id="textviewSwoo" text="Nudge, nudge. Wink, wink. Say no more!"/> </if> ... <textview label="Here's the text of the hidden textview again:" text='{ifAoo.textviewSwoo.text
}'/>
Sample
<form id='if' menuName='Show/hide elements in a form' platforms='web' xmlns='http://schemas.mobilengine.com/fls/v1'> <checkbox id="checkboxBroo" text="Know what I mean? Know what I mean?"/> <if id="ifAoo" cond='{checkboxBroo.checked}'> <textview text="Nudge, nudge. Wink, wink. Say no more!"/> </if> </form>
The
child control of the if
is displayed only when the
checkboxBroo checkbox is selected
{ checkboxBroo: {checked: true}, ifAoo: {cond: true}, ...}
See the workflow script reference guide for more details on data type mapping.