Start page
Start page

Start page / Template development / Rules / Form properties <PROPERTY/> / Property EMPTY

EMPTY property

Empty value check for input components

Input components can contain a value or be “empty”. If no value is stored in the input component, this can, depending on the type of input component, return either an:

The expression <PROPERTY source="gadget" name="EMPTY"/> can be used in the area Value determination of the rule definition (or for the definition of a precondition), and checks whether a value was saved for an input component (or preassigned in the template) or whether the input component is empty. The expression returns a Boolean value:

<PROPERTY source="gadget" name="empty"/>

Returns:

Input component contains a value (set="1")

FALSE

Input component contains no value (set="0"). No default value is specified.

TRUE

Input component contains no value (set="0"). A default value with preset="default" is specified.

FALSE

Input component contains no value. A (persistent) preset value is specified with preset="copy" (set="1").

FALSE

Input component contains an empty value (set="1")

TRUE

  
Important It is to be checked whether an input component delivers NULL; this can be done via the tag <NOT_NULL/>.

Examples

Example 1) Simple empty check for an input component

The following form contains two input components. The input component “cs_picture” (of type FS_REFERENCE) for selection of an image and “cs_description” (of type CMS_INPUT_TEXTAREA) for input of an image description.

Via a dynamic form, it is to be ensured that the input component “cs_description” must be filled if the input component “cs_picture” is not empty.

In addition, a precondition is defined which initially checks whether an image is referenced in the input component “cs_picture”. If the precondition is fulfilled (“cs_picture” is not empty), the <WITH/> section is checked to determine whether the input component “cs_description” is empty. The result of this check is a Boolean value, which then is linked in the <DO/> section with a validation of the input component. As long as the condition (“image description is not empty”) is not fulfilled, the <VALIDATION/> section of the rule is run and a correction notice appears. Through the surrounding <ON_SAVE/> tags, saving the form is also prevented.

...
<ON_RELEASE>
<IF>
<NOT>
<PROPERTY source="cs_picture" name="EMPTY"/>
</NOT>
</IF>
<WITH>
<NOT>
<PROPERTY source="cs_description" name="EMPTY"/>
</NOT>
</WITH>
<DO>
<VALIDATION>
<PROPERTY source="cs_description" name="VALID"/>
<MESSAGE lang="*" text="The editor must not be empty!"/>
<MESSAGE lang="DE" text="Der Editor darf nicht leer sein!"/>
</VALIDATION>
</DO>
</ON_RELEASE>
....

Note: This definition is not necessarily suitable for being edited with InEdit. See also page Display of rule violations in ContentCreator.

Example 2) Preventing saving a form with empty input components

The following example prevents saving a form if at least one input component of the form was not filled with content. The rule is evaluated language-dependently. In addition, within the precondition, it is first ensured that the editor edits the form in the project master language. This evaluation is particularly important with very restrictive rules, which as in this example prevent the saving of a form. The rule developer should consider that not all languages are visible or editable for every rule developer:

...
<ON_SAVE>
<IF>
<EQUAL>
<PROPERTY source="#global" name="LANG"/>
<PROPERTY source="#global" name="MASTER"/>
</EQUAL>
</IF>
<WITH>
<NOT>
<AND>
<PROPERTY source="st_headline" name="EMPTY"/>
<PROPERTY source="st_text" name="EMPTY"/>
<PROPERTY source="st_picture" name="EMPTY"/>
</AND>
</NOT>
</WITH>
<DO>
<VALIDATION>
<PROPERTY source="st_headline" name="VALID"/>
<MESSAGE lang="*" text="No content provided!"/>
<MESSAGE lang="DE" text="Es wurde kein Inhalt erfasst!"/>
</VALIDATION>
<VALIDATION>
<PROPERTY source="st_text" name="VALID"/>
<MESSAGE lang="*" text="No content provided!"/>
<MESSAGE lang="DE" text="Es wurde kein Inhalt erfasst!"/>
</VALIDATION>
<VALIDATION>
<PROPERTY source="st_picture" name="VALID"/>
<MESSAGE lang="*" text="No content provided!"/>
<MESSAGE lang="DE" text="Es wurde kein Inhalt erfasst!"/>
</VALIDATION>
</DO>
</ON_SAVE>
...

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