XForms 输入中的默认值
我有一个 XForm,其中某些字段可能经常留空(可选街道地址)。是否有技术可以为该字段设置默认值,最好是一个空格(我遇到了奇怪的 CSS 格式问题)。 value=""
的 html 表单方式不起作用,在 XML 模式中设置默认值也不起作用。
示例:
<xforms:input ref="clientaddress/streetaddress2" model="model_inventory" >
<xforms:label>Street Address (Line 2)</xforms:label>
将此字段留空会导致生成的 xml 文档中的
我想要
<streetaddress> </streetaddress>
I have an XForm that has certain fields that may often be left blank (optional street address). Is there is technique to set a default value for that field, preferably a space (I am running into weird formatting issues with CSS). The html form way of value=""
doesn't work, neither does setting a default value in the XML schema.
EXAMPLE:
<xforms:input ref="clientaddress/streetaddress2" model="model_inventory" >
<xforms:label>Street Address (Line 2)</xforms:label>
Leaving this field blank results in <streetaddress2/>
in the resulting xml document
I want
<streetaddress> </streetaddress>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是说您想将实例中所有空白字段的值设置为有空格吗?假设您有一个静态实例,您可以将以下内容添加到模型中:
请注意,这使用 Orbeon Forms 的
xxforms:iterate
扩展 (记录在此处)。如果您正在使用另一个 XForms 实现,您可能需要检查该实现的文档以查看它们是否提供类似的扩展。(话虽这么说,我很好奇为什么你需要在“空”字段中留有一个空格。这可能是其他地方出现问题的迹象吗?)
Are you saying that you would like to set the value of all the fields in your instance that are blank to having a space? Assuming you have a static instance, you can add the following to your model:
Note that this uses the
xxforms:iterate
extension of Orbeon Forms (documented here). If you are using another XForms implementation, you might want to check the documentation of that implementation to see if they provide a similar extension.(This being said, I am curious as to why you need to have a space in the "empty" fields. Could that be a sign of a problem somewhere else?)
在 XForms 中设置默认值的最简单方法是实例:
您说过,您尝试在模式中设置默认值,但我不确定它是否按您的预期工作。模式可用于验证,但我不知道是否有任何 XForms 引擎使用模式的默认值。
The easiest way to set default value in XForms is the instance:
You said, that you tried to set default value in schema, but I'm not sure that it works as you expected. Schema can be used for validation, but I don't know if any XForms engine uses schema's default values.