Skip to main content
marcusm0003
February 10, 2023
Solved

a!radioButton() how do I disable only one of the choiceLabels options upon conditions met?

  • February 10, 2023
  • 3 replies
  • 2 views

Hi team, I been pondering and I would like to disable only the "direct approve" option upon conditions met. Is that possible?

a!localVariables(
local!choiceLabels: {
approve,
reject,
direct approve,
direct reject
},
a!radioButtonField(
                  label: "This application is recommended for",
                  labelPosition: "ABOVE",
                  choiceLabels: local!choiceLabels,
                  choiceValues: local!choiceValues,
                  value: ri!recommendedFor,
                  saveInto: {},
                  disabled: since it allowed only true()/false()?
                  )
                 
                

Best answer by harshitb6843

Not really. Either you disable all the options or keep all of them enabled. 
A workaround is to create multiple radioButtonFields for each option and then control their disabled state individually. 

3 replies

harshitb6843
February 10, 2023

Not really. Either you disable all the options or keep all of them enabled. 
A workaround is to create multiple radioButtonFields for each option and then control their disabled state individually. 

marcusm0003
February 14, 2023

For other users: Another good alternative is to also hide so dont have to hardcode the same saveInto values multiple times. Thanks for your answer!

csteward
February 10, 2023

Additionally, what I generally do here is to manage the selection options in a local refresh variable and continue to use a single radio button or dropdown, such as:

a!localVariables(
  local!canApproveDirect: true,
  local!options: {"Approve","Reject","Direct Approve","Direct Reject"},
  local!choices: a!refreshVariable(
    value: if(
      local!canApproveDirect,
      local!options,
      index(local!options,{1,2})
    )
  ),
  local!selection,
  {
    a!radioButtonField(
      label: "Direct Approvals",
      choiceLabels: {"Yes","No"},
      choiceValues: {true,false},
      value: local!canApproveDirect,
      saveInto: {
        local!canApproveDirect,
        a!save(local!selection,null)
      }
    ),
    a!radioButtonField(
      label: "This application is recommended for",
      labelPosition: "ABOVE",
      choiceLabels: local!choices,
      choiceValues: local!choices,
      value: local!selection,
      saveInto: local!selection
    )
  }
)