Making XForms enforce the constraint and type model item properties only when field is populated

情到浓时终转凉″ 提交于 2019-12-12 18:06:21

问题


I have a simple XForm with an input field where I have specified the field to be optional with the required="false()" property. However, I would like add a type and constraint property to the field to enforce an integer type and that the integer must be greater than 10, but only if data is entered in the field; after all, the field is optional. For example:

<xf:bind nodeset="testGreaterThanTen"
         required="false()"
         type="xs:integer"
         constraint=". &gt; 10"/>

I would have thought the required="false()" would trump the type and constraint properties, but I appear to be wrong; it appears that including the type and constraint forces the field to be filled out. Is this the proper behavior per the XForms 1.1 specification? Is there anyway to do what I want in XForms?

Thanks!


回答1:


Try type="xforms:integer" instead of type="xs:integer". Orbeon supports the XForms 1.1 types this way since 2007 (see the Release Notes for Orbeon Forms 3.6, fourth point of "Noteworthy Changes" and issue #307162).



来源:https://stackoverflow.com/questions/8667849/making-xforms-enforce-the-constraint-and-type-model-item-properties-only-when-fi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!