Style conditionalContainer

A section of style conditionalContainer wraps its content in an invisible container (exactly like the style div). However, a logic condition can be attached to the container such that the content is only displayed if the condition resolves to true.

The field condition allows to specify the conditioon. Note that the field condition is of type json and requires

  1. valid json syntax (see https://www.json.org/)
  2. a valid condition structure (see https://github.com/jwadhams/json-logic-php/)

A condition is written in the form

{"<operator>": [<operand_1>, <operand_2>, ... , <operand_n>]}

where <operator> is one of the following:

  • comparison operators: ==, !=, >, <, <=, >=
  • logic operators: and, or
  • arithmetic operators: +, -, /, *, %, max, min

and <operand_*> is either

  • a condition (of the form as defined above)
  • a literal (number or text)
  • a form-field
  • a group name

In order to check if the user belongs to a group the $ sign is used for the group name and the evaluation returns true or false if the user belongs to the group.

Example: { "==" : [true,"$subject"] } This code will check if the logged in user belongs to group subject.

In order to refer to a form-field use the syntax "@<form_name>#<from_field_name>" (the quotes are necessary to make it valid json syntax) where <form_name> is the value of the field name of the style formUserInput and <form_field_name> is the value of the field name of any form-field style (see input styles).

Unknown Style styleSignature

Example

The following example is constructed with a

  • formUserInput with field is_log unchecked, name set to "form_selector", and label set to "Update". The form has the follwing element as child:
    • a radio input with field name set to "field_selector" and items set to
      [{
      "value":"1",
      "text": "female"
      },
      {
      "value":"2",
      "text":"male"
      }]
  • two conditionalContainers where one has a female image as child element and the other has a male image as child element.

The condition for the conditionalContainer with the female image is set to

{"==":[1, "@form_selector#field_selector"]}

The condition for the conditionalContainer with the male image is set to

{"==":[2, "@form_selector#field_selector"]}

Note that the condition compares the form field @form_selector#field_selector with either the value 1 or 2 which correspond to the values of the radio button inputs.