XForms relation of 'constraint' and 'required' properties

Posted by Danny on Stack Overflow See other posts from Stack Overflow or by Danny
Published on 2012-04-11T11:29:25Z Indexed on 2012/04/11 23:29 UTC
Read the original article Hit count: 250

Filed under:
|
|
|

As a reference, the most similar question already asked is: http://stackoverflow.com/questions/8667849/making-xforms-enforce-the-constraint-and-type-model-item-properties-only-when-fi The difference is that I cannot use the relevant properties since I do want the field to be visible and accessible.

I'm attempting to make a XForms form that has the following properties:

  1. It displays a text field named 'information'. (for the example)
  2. This field must not be required, since it may not be necessary to enter data. (Or this data will be entered at a later time.)
  3. However, if data is entered in this field, it must adhere to the specified constraint.
  4. I cannot mark the field as not relevant since this would hide the field and some data may need to be entered in it.

The trouble now is that even though the field has no data in it, the constraint is still enforced (i.e. even though it is not marked as 'required').

I have taken a look at the XForms 1.1 specification, however it does not seem to describe how the properties 'required' and 'constraint' should interact.

The only option I see, is to add a part to the constraint such that an empty value is allowed. e.g.:

. = '' or <actual-constraint>

However, I don't like this. It feels like a workaround to add this to every such field.

Is there any other way to express that non-required fields should not need to match the constraint for that field? (Am I missing something?)

© Stack Overflow or respective owner

Related posts about constraints

Related posts about orbeon