Start page
Start page

Start page / Template development / Rules / Value determination <WITH/>

<WITH/> Determining values

Every rule initially determines a value that can be based on one or more properties of the form (“In which editorial language is the form edited?”) or an individual form element (“Is the value of the component NULL?”). The desired properties are taken into consideration in the value determination of the rule definition.

A value determination is defined with a <WITH/> section. This section must be defined within the tags that define a restriction level and before the tags that initiate a handling instruction. Insofar as a precondition is defined for the rule, the value determination is defined according to the precondition.

In the process, the following applies for the definition of a value determination:

  • For each rule, a value determination must be defined.
  • In the simplest case, the template developer can define a constant (<TRUE/>, <FALSE/>, <TEXT/>, <NUMBER/>) within the <WITH/> section.
  • The value determination, however, can also be considerably more complex and refer to values or properties of the form or a form element. The specification of a<PROPERTY/> tag is then necessary within the value determination tag. Through
    • logical (<AND/>, <NOT/>, <OR/>),
    • comparative (<EQUAL/>, <GREATER_THAN/>, <LESS_THAN/>, <NOT_NULL/>), or
    • regular expressions (<MATCHES/>),
  • additional values can be derived. The value of the input component, for example, can be checked against certain regular expressions or against a comparison value.
  • The result of the value determination (Boolean value, text, date, etc.) is passed on by the FirstSpirit framework during the execution of the rule and can be linked with the appropriate handling instruction by the rule developer.

Examples

Example 1) Determining the Boolean value and link it to a validation

A form has one entry field each for a creation date (“st_creationDate”) that is automatically assigned and an expiration date (“st_endDate”) that is entered by the editor. A dynamic form should guarantee that the expiration date entered by the editor should lie after the creation date.

Within the <WITH/> section, the values of both input components are first retrieved through a <PROPERTY/> tag and then a simple <GREATER_THAN/> check is performed on both values. The result of this check is a Boolean value that is then linked with a validation in the <DO/> section. As long as the condition (“expiration date lies after the creation date”) is not fulfilled, the <VALIDATION/> section of the rule is executed.

<RULES>
<ON_RELEASE>
<WITH>
<GREATER_THAN>
<PROPERTY source="st_endDate" name="VALUE"/>
<PROPERTY source="st_creationDate" name="VALUE"/>
</GREATER_THAN>
</WITH>
<DO>
<VALIDATION>
<PROPERTY source="st_endDate" name="VALID"/>
<MESSAGE lang="*" text="Please enter a valid date"/>
<MESSAGE lang="DE" text="Bitte geben Sie ein gültiges Datum"/>
</VALIDATION>
</DO>
</ON_RELEASE>

</RULES>

Example 2) Determine the values and link them to a handling instruction

Instead of a Boolean value (see example 1), the value determination can return a result quantity.

The following form contains two input components of the type CMS_INPUT_COMBOBOX, whose value quantity is automatically from a database table. The dynamic form should now guarantee that only the products of the selected supplier are displayed after it is selected from the “st_supplier” selection list when the “st_dish” combo box is opened. The selection from the first selection list thus influences the selection quantity of the dependent, second selection list.

Within the <WITH/> section, the value of the first input component is retrieved through a <PROPERTY/> tag. The result of this value determination is then linked to a handling instruction in the <DO/> section of the rule. In this case, no validation is executed, but rather the value quantity of the “st_dish” input component is filled dynamically with values from a database table through an additional <PROPERTY/> tag (cf. CMS_INCLUDE_OPTIONS). In the process, the determined value from the “st_supplier” combo box acts as the key.

<RULES>
<ON_EVENT>
<WITH>
<PROPERTY source="st_supplier" name="VALUE"/>
</WITH>
<DO>
<PROPERTY source="st_dish" name="query.supplier_id"/>
</DO>
</ON_EVENT>
</RULES>

© 2005 - 2015 e-Spirit AG | All rights reserved. | Last change: 2015-02-18