Wednesday, July 17, 2013

Enhanced validation in Form Builder and Form Runner

A major new feature of the upcoming Orbeon Forms 4.3 is enhanced validation. Up to 4.2, you could validate a control value with:
  • whether a value is required
  • a data type such as "integer" or "email"
  • a single XPath constraint
If any of these validations failed, the user would get either a custom alert message for the control, or a generic Form Runner alert message.

With Orbeon Forms 4.3, this is still available but is improved in the following ways:
  • You can now set multiple XPath constraints, each with its own alert message.
  • You can, in addition to errors, create warnings and informational messages.
The user interface of Form Builder has been updated to reflect this. We used to have two separate dialogs to modify information associated with a control: a "details" dialog and a "validation" dialog. We haven't been happy about this for a long time as the distinction appeared arbitrary. So they are now unified and functionality is separated by tabs:
  • Basic Settings
  • Validations and Alerts
  • Formulas
  • Help Message
The tab relevant to validation is called, well, "Validation and Alerts":

This might look scary at first, but in fact things are pretty simple: each line represents a separate validation. The first two validations (whether the control is required and the data type) are fixed. All the other validations are optional and are constraints validations.

Each constraint validation has the constraint itself, expressed in XPath, a level, and an alert message.

There are three main use cases for adding multiple constraints:
  • For readability, so that individual constraints are simpler.
  • In order to provide a separate alert message for each constraint.
  • In order to specify other constraint levels.
The notion of constraint level is new in 4.3. Up to now, any failed validation was was an error. Now you can add constraints that just warn the user, or display an informational message. Here is an example of warnings and informational messages appearing in a simple form:

As was the case before, messages appear as needed right under the controls, as well as in the error summary at the bottom of the page. In addition, the form title in the browser and badges in the navigation bar indicate the validation status of the form.

The difference between the error level and the warning and info levels is that the latter do not prevent form data from being submitted. Instead, if there are warnings or informational messages, then a confirmation dialog shown the user before submitting the data:

The submission process, by the way, is fully configurable via the processes mechanism (see the blog post and doc).

This post just covers the basics! For the reference documentation, see Form Builder ~ Validation. We hope you like this feature!

1 comment:

  1. I have wanted separate warning from critical errors in the past. This will be very useful.

    The idea of multiple Alert messages will also be nice to give users precise messages on how to correct a field value.

    Looking forward to trying out 4.3!

    - Dan