Save default values for radio button

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.

  Discussion posts and replies are publicly visible

Parents
  • 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).

Reply
  • 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).

Children
No Data