From GeoMedia Smart Client
Jump to: navigation, search
GMSC 2013/2014 Javascript API Overview Form Events Types Utility Functions client-side Validation Conditions Interaction with SmartClient Cookbook Cheatsheet

Form Conditions

Form Conditions allow the continous manipulation of the form in reaction to user events. Via form conditions, form fields, groups or tabs can be disabled or hidden depending on the field value of another form field. Form Conditions are evaluated every time an input in the entire form happens, so they allow an almost real-time reaction to user inputs. Note that form conditions can't contain arbitrary Javascript statements, but are restricted to the following structure:

  • IG.hasValue({FORM.ID_OF_FIELD}) true if the field contains a value or is checked
  • IG.hasNoValue({FORM.ID_OF_FIELD}) true if the field doesn't contain a value or is not checked
  • IG.eval({FORM.ID_OF_FIELD}) === "DesiredValue") true if the field contains "DESIRED_VALUE" (case-insensitive comparison)

Note: the {FORM. part in {FORM.ID_OF_FIELD} is static, you only need to change the id of your field. Example: If the id of your form field is MyField, the expression looks like this: {FORM.MyField}

Use Cases for form conditions

  • Show parts of the form if the user clicks a checkbox and keep them hidden otherwise. Example: show the form group "Postal Address for confirmation notice" when the user checks the checkbox "Send confirmation via letter" (and hide it again when the user unchecks the checkbox)
  • Disable parts of the form that became obsolete because of user input. Example: disable the field "Coordinate Input" if the user chose to use the project coordinates instead of entering them by himself.

Note: disabling form elements turns them into read-only mode. the values of their contained form fields are nevertheless submitted to the server.


Condition meaning
visible="hidden[SCRIPT[IG.hasValue({FORM.MasterCheckbox})]]" The field is initially hidden, but gets visible if the checkbox field "MasterCheckbox" is checked.
visible="hidden[SCRIPT[IG.hasNoValue({FORM.MasterCheckbox})]]" The field is initially hidden, but gets visible if the checkbox field "MasterCheckbox" is NOT checked.
editable="SCRIPT[IG.hasValue({FORM.MasterCheckbox})]" The field is editable if the checkbox field "MasterCheckbox" is checked.
editable="SCRIPT[IG.hasNoValue({FORM.MasterCheckbox})]" The field is editable if the checkbox field "MasterCheckbox" is NOT checked.

Propagated form conditions

Since GMSC 2014 form conditions are propagated downwards the form: conditions applied to tabs or groups also are effective on elements below them (e.g. form fields).

If one form element is affected by more conditions because it inherited conditions from "higher" form elements, these conditions are evaluated sequentially and joined by a Boolean AND operator.

The following example shows the tree representation of a form with two form conditions applied: one in the formgroup Group21 (which depends on the value of MasterCheckbox111), one in the child field Field211 (which depends on MasterCheckbox112).

   |---- Tab1
   |      |----Group11
   |              |----MasterCheckbox111
   |              |----MasterCheckbox112
   |---- Tab2
          |----Group21 editable="SCRIPT[IG.hasValue({FORM.MasterCheckbox111})]"
                 |----Field211 editable="SCRIPT[IG.hasValue({FORM.MasterCheckbox112})]"

In this configuration, the editable states of the two fields in Group21 will be evaluated like this:

  • field Field211 will only be editable if both MasterCheckbox111 and MasterCheckbox112 are checked (the conditions of the field itself and the one inherited from parent group must evaluate to true).
  • while its sibling field Field212 will be editable if MasterCheckbox111 is checked, since this form field has no form condition applied and just inherits the condition of the parent form group Group21.

Note: in GMSC 2013 the propagation of form conditions did not work correctly, therefore it is not recommended to apply multiple form conditions in the same branch of a form tree (e.g. condition on a field and its parent group)