使 XForms 仅在填充字段时强制执行约束和类型模型项属性
我有一个带有输入字段的简单 XForm,其中我已使用 required="false()" 属性指定该字段为可选字段。但是,我想向字段添加类型和约束属性以强制执行整数类型,并且整数必须大于 10,但前提是在字段中输入数据;毕竟,该字段是可选的。例如:
<xf:bind nodeset="testGreaterThanTen"
required="false()"
type="xs:integer"
constraint=". > 10"/>
我本以为 required="false()" 会胜过类型和约束属性,但我似乎错了;看来,包括类型和约束会强制填写该字段。根据 XForms 1.1 规范,这是正确的行为吗?无论如何,有没有办法在 XForms 中做我想做的事情?
谢谢!
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=". > 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
type="xforms:integer"
而不是type="xs:integer"
。 Orbeon 自 2007 年起就以这种方式支持 XForms 1.1 类型(请参阅Orbeon Forms 3.6 的发行说明,“值得注意的更改”的第四点和问题#307162)。Try
type="xforms:integer"
instead oftype="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).