This page demonstrates how to use an array of structs to provide server-side validation errors to the form. View the code used to generate the form.


Choices, Choices

cfUniForm supports two conventions for building your errors array. Provide the name of the property that failed validation in your choice of a 'property' key or a 'field' key.

The array of structs: Property Key

Array
1
Struct
MESSAGE
stringPlease enter your Email Address.
PROPERTY
stringemail
2
Struct
MESSAGE
stringThe passwords do not match.
PROPERTY
stringpassword
3
Struct
MESSAGE
stringThe Email Address is invalid.
PROPERTY
stringemail

The array of structs: Field Key

Array
1
Struct
FIELD
stringemail
MESSAGE
stringPlease enter your Email Address.
2
Struct
FIELD
stringpassword
MESSAGE
stringThe passwords do not match.
3
Struct
FIELD
stringemail
MESSAGE
stringThe Email Address is invalid.

Note that the two 'email' error messages are not in order. However, when the messages are displayed by cfUniForm, they are grouped by field (property) name. See the demo form below.

The Rendered Form:

Oooops! Invalid Fields!

The following errors were detected in your form. Please fix the offending fields and re-submit.

  1. Please enter your Email Address.
    The Email Address is invalid.
  2. The passwords do not match.
Account Registration

Please enter your Email Address.
The Email Address is invalid.

Note: Please enter a valid email

Note: Please re-type your email.

The passwords do not match.