m.makos
m.makos

Reputation: 85

Orbeon forms - clear dropdown label

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:

  1. In the country_1 dropdown I choose something.
  2. In the country_2 dropdown I choose something.
  3. In the country_1 dropdown I change value. country_2 should be cleard.
  4. 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: enter image description here

Upvotes: 0

Views: 129

Answers (1)

avernet
avernet

Reputation: 31743

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>

Upvotes: 1

Related Questions