Skip to main content
March 29, 2022
Question

Save default values for radio button

  • March 29, 2022
  • 4 replies
  • 0 views

How can I assign a default value to a radio button and make sure that value is saved even if the user doesn't interact with a radio button component?

for instance, if I have local!radioButtonDefaultValue: false

I see that the No label is selected, when value field of the component is set to local!radioButtonDefaultValue but the value itself isn't saved automatically unless the user interacts with the radio button component. I want to save the false value even if there is no interaction with the component.

4 replies

gopalk2865
Participating Frequently
March 29, 2022

Hi Amit, You can set the value as true or false in your process variable itself , so when your process starts , your rule input will have by default value from the pv. you can also save this value in any other field's saveInto. i hope it helps.

harshitb6843
March 29, 2022

Hi there,

When creating the variable, define its value or use a script task after the start node to set the desired value of the desired variable. 

peter.lewis
Employee
March 29, 2022

Personally I take a different approach than others have suggested (defaulting data in the process model) - instead I usually use local variables to set a default value for fields and then use a button click to then transfer the results to the corresponding local variable. The advantage of this method is that your form can not be tested entirely on its own.

For example, given your default value above, you could do something like this:

a!localVariables(
  local!radioButtonDefaultValue: false,
  a!formLayout(
    label: "Test Form",
    contents: {
      a!radioButtonField(
        label: "Status",
        choiceValues: {true, false},
        choiceLabels: {"Active", "Inactive"},
        value: local!radioButtonDefaultValue,
        saveInto: local!radioButtonDefaultValue
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: a!buttonWidget(
        label: "SUBMIT",
        submit: true,
        saveInto: a!save(
          target: ri!status,
          value: local!radioButtonDefaultValue
        )
      )
    )
  )
)

The button click always works well because it's guaranteed that they must click the button to move on (and it will always be the last thing they do on the form).