OpenWGA 7.1 - WebTML reference

WebTML tags


Description :
This tag defines global validations for the current tmlform. A validation is defined as TML script expression within the attribute condition and should evaluate to 'true' if the form values are correct. The expression is automatically executed on TML default actions which will modify data such as "$store" or by calling "tmlform.storeInContent(), "tmlform.storeInProfile()", "tmlform.storeInPortlet()" or "tmlform.storeInDocument()". To manually validate a form "tmlform.validate()" can be used.

The tag body contains the error message. If a validation fails the save will be canceled and the backend data for e.g. the content will not be modified. In this case the tag will render the body.

In addition the message is also registered on the tmlform object and can be accessed via tmlscript or <tml:formmessages/>.

If the validation tag should not render the body and display the error message the attribute 'output=false' can be used.

Within a <tml:form> tag the validate tag is related to the current form. Outside a <tml:form> the corresponding form can be specified via id by using the attribute 'sourcetag'.
Derived from: Attributes:
show inherited attributes ...
Name Value(s) Purpose
cleariferror field-name, field-name, ... Defines a list of <tml:input> fields which values are cleared if this validation fails.
condition tmlscript-expression Defines the TML script expression for this validation.
ifnoerror field-name, field-name, ... Defines form fields which must be valid before this validation tag is executed.
sourcetag tag-id Defines the id of a TML form tag this validation refers to.

<tml:validate/> can be used to perform form validations which could not be assigned to single form fields. The following validation checks two date values and their order:

Start date: <tml:input name="datefrom" type="date" validation="$P_VALUE!=null" message="Please enter a start value"/>
End date: <tml:input name="dateto" type="date" validation="$P_VALUE!=null" message="Please enter an end value"/>

<tml:validate condition="!tmlform.datefrom.after(tmlform.dateto)" ifnoerror="datefrom,dateto">
    The start date must not be later than the end date!

The attribute "ifnoerror" defines that the validation on <tml:validate> should only be executed if both fields "datefrom" and "dateto" are valid. In this combination you can be sure that "datefrom" and "dateto" contains valid date objects before checking the order.