Thursday, February 14, 2019

Hidden fields

Orbeon Forms 2018.2 introduce a new form control in the toolbox called Hidden Field.

Now you might wonder why you would always hide a form field. There are two major use cases:
  • Holding intermediary calculations:  If the control has a "Calculated Value" and/or "Initial Value" formula, it can be referred to by variable name (like $my-intermediary-result) from other formulas.
  • Handling out-of-band validations: If the control has a label, alert and validations, a failing validation will show in the Error Summary. In addition, this also impacts the Wizard View's lax and strict validation modes, preventing forward navigation until the error is fixed by the user.
It has always been possible, with Form Builder, to hide any field by setting its visibility using the false() formula, or, with Orbeon Forms 2018.2, by selecting the option "No".

Control Visibility
But hiding a field this way can have unintended consequences. In particular, the control becomes in effect non-existent in the user interface when it comes to value change events which are useful in actions, and valid/invalid events which are used for validation. So even if the value of a non-visible control is invalid, the form is considered valid.

As a workaround, you can place a CSS class to hide a Calculated Value control to the user. The drawback of this is that the value of the control is still visible in the browser using "View Source" or development tools so this workaround cannot be used for sensitive data which the user should never see.

The new Hidden Field control, on the other hand, works like a regular control such as a Text Field in all respects, including events, validation, and alerts. Except, of course, that it doesn't show to the user at runtime. In particular, its value is guaranteed to stay on the server.

At design-time, in Form Builder, the control shows as a box with an icon so that the form author knows that a hidden control is in use. You can move that control and modify its properties like with any other form control.

Hidden Field in Form Builder
See also the documentation for details. We hope you will like this feature of Orbeon Forms 2018.2.

No comments:

Post a Comment