如何让 XForm 显示复选框?
我似乎在让 xform
显示复选框时遇到问题 - 相反,它显示的是文本区域。我的所有其他项目都工作正常,我只是似乎无法让这个项目工作。
这是我的模型中的代码:
<takeMoneyOff type="xs:boolean"/>
// close the my structure
// close the instance
<xf:bind id="takeMoneyOff" nodeset="/xForm/takeMoneyOff"/>
// close the model
而这一切所指的显示项目是:
<xf:input ref="takeMoneyOff" class="takeMoneyOffClass">
<xf:label>Take Money Off? </xf:label>
</xf:input>
I seem to be having problems getting a xform
to display a check box -- instead it is displaying a text area. All my other items are working correctly, I just can't seem to get this one to work.
This is the code inside my model:
<takeMoneyOff type="xs:boolean"/>
// close the my structure
// close the instance
<xf:bind id="takeMoneyOff" nodeset="/xForm/takeMoneyOff"/>
// close the model
And the item this is all referring to for display is:
<xf:input ref="takeMoneyOff" class="takeMoneyOffClass">
<xf:label>Take Money Off? </xf:label>
</xf:input>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有提及您所针对的 XForms 实现,但假设它是/它们完全一致,您有两个选择。
如果要指定实例数据中的类型(如示例代码所示),则需要将 type 属性置于 XML 架构实例命名空间中。因此,如果您已声明命名空间前缀
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
,您的实例数据将需要如下所示:< /p>You don't mention which XForms implementation(s) you are targeting, but assuming that it is / they are fully conformant, you have two options.
If you want to specify the type in the instance data, as your example code indicates, you need the type attribute to be in the XML schema instance namespace. So, if you've declared the namespace prefix
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
, your instance datum would need to look like this:Alternatively, if the instance data is coming from an external source and you're not in control of it, then you can place a type attribute on the bind element itself instead (it should not be in the xsi namespace in this case):
您还可以使用
,它将存储值或空白:通过适当的绑定,您甚至可以在出现空白时存储“false”:
You can also use
<xforms:select>
, which will store a value or blank:With the appropriate bind, you could even store "false" when a blank appears: