Orbeon 表单 - 清除下拉标签 [英] Orbeon forms - clear dropdown label
问题描述
我有 2 个下拉列表(country_1 和 country_2)填充国家/地区.两者都是必需的.如果我在 country_1 下拉列表中选择 value some,则应该清除 country_2 下拉列表(值和标签).
示例:
- 在 country_1 下拉菜单中,我选择了一些东西.
- 在 country_2 下拉列表中,我选择了一些内容.
- 在 country_1 下拉列表中,我更改了值.country_2 应该被清除.
- 当我验证表单时,我在 country_2 下拉列表中出现错误(因此似乎该值已被清除).
我希望在第 3 步中 country_2 将有空标签.
我在 country_1 下拉列表中添加了值更改操作,这应该清除 country_2 下拉值和标签.
示例形式:
将您的代码移到
中即可解决问题.我已经在 demo.orbeon.com
上更新了您的表单,但如果它消失了,这是我直接放在 <xf:model>
中的代码段:
<xf:action if="//c_country_1 != 'af'"><xf:setvalue ref="//c_country_2"/><xf:setvalue ref="//c_country_2/@label"/></xf:action></xf:action>
I have 2 dropdowns (country_1 and country_2) populate with countries. Both are required. If I choose value some in the country_1 dropdown, the country_2 dropdown should be cleared (value and label).
Example:
- In the country_1 dropdown I choose something.
- In the country_2 dropdown I choose something.
- In the country_1 dropdown I change value. country_2 should be cleard.
- When I validate form I get error on country_2 dropdown (so it seems that the value has been cleared).
I would like to in step 3 the country_2 will have empty label.
I have added value change action to country_1 dropdown, that should clear country_2 dropdown value and label.
Example form: https://demo.orbeon.com/demo/fr/orbeon/builder/edit/bc71b6532f4faee1ec711105a2db00bb65995d80
Source code: https://gist.github.com/mmakos-profidata/9728f086da3abc7bd96af27c8d5a70b8
Error screen:
Moving your code to be inside the <xf:model>
does the trick. I've updated your form on demo.orbeon.com
, but in case it disappears, this is the snippet that I put directly inside the <xf:model>
:
<xf:action event="xforms-value-changed" observer="c_country_1-control">
<xf:action if="//c_country_1 != 'af'">
<xf:setvalue ref="//c_country_2"/>
<xf:setvalue ref="//c_country_2/@label"/>
</xf:action>
</xf:action>
这篇关于Orbeon 表单 - 清除下拉标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!