orbeon

Orbeon: Reset All Form Fields


At the top of the form we have a radio-button that has 3 options. Each option takes the user down a different set of questions. However, it the user changes their mind and say, swaps from option-1 to option-2. Then we want to reset all the form fields except the radio-button.

I have tried syntax such as the following which does clear dropdowns and checkboxes, but it sets a text field to "true":

<xf:setvalue xxf:iterate="//SubScn2//*[empty(*)]" value="if (//MainCtrl = '1') then 'true' else ."/>

Form example: https://demo.orbeon.com/demo/fr/orbeon/builder/edit/4d48d3f7be57ecaeecb2d5c14ce2a50cf85f7475

Any suggestions?


Solution

  • I think your code is good. If you wanna clear all field just use value="if (//MainCtrl = '1') then '' else .". If you want except some fields so make xPath in xxf:iterate="//SubScn2//*[not(self::SubScn2_C3)]" more specific. Some like "//SubScn2//*[empty(*) and not(self::SubScn2_C3)]". If you use good names for fields, that condition could look more generally.