Search code examples
formsif-statementcalculated-columnsorbeon

How to pre-fill the Orbeon text field based on selection on radio button


I am creating an Orbeon form. There is a radio button (control-114) field and a text field (control-111).

  • radio button has two value 1 and 2 (string input)
  • if value 1 is selected, text field is empty (allowing user to fill)
  • if value 2 is selected, text field is per-populated with 'xxx-xxx-xx'

I tried the following syntax in the calculated value:

 if($control-114='1') then $control-111='1' else '' 

Solution

  • You were almost there with that expression! In the "Control Settings", "Formulas", "Calculated Value" for control-111 (the text field), you'll want to have:

    if($control-114 = '2') then 'xxx-xxx-xx' else .
    

    Also, in "Read-Only", you should mark the field explicitly as not read-only, with the following, otherwise fields with a "Calculated Value" automatically become read-only.

    false()