How to deselect a radio button option?

Certified Lead Developer

Hello,

We have a use case where user needs to select only one option out of multiple options. It is not a mandatory field. Radio button helps in ensuring only one option is selected. However, it doesn't allow user to deselect the option. We tried to set the value of Radio button as null when user is selecting the same option again. But it didn't work.

Hence, we are currently using multiple checkbox fields to handle this use case.

Is there a better approach to handle this scenario?

 

Thanks in advance.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    With the advent of Rich Text Links, Rich Text Icons, and the Side-By-Side Layout options, we can probably come up with some creative solutions to this problem now.  In the past I always did what some prior commentors suggested and just put a "None" or "N/A" option.  But this got me thinking.

    What if we used a rich text icon with a dynamic link configured such that it shows up right next to the radio button values?

      ---> 

     

     Here's the code (18.1 required) I came up with for the above:

    load(
      local!radioValue,
      
      a!sectionLayout(
        label: "Radio Button",
        contents: {
          a!textField(
            label: "Text",
            value: "asdf"
          ),
          a!sideBySideLayout(
            alignVertical: "BOTTOM",
            items: {
              a!sideBySideItem(
                width: "MINIMIZE",
                item: a!radioButtonField(
                  label: "Radio",
                  choiceLabels: {"A", "B"},
                  choiceValues: {"A", "B"},
                  value: local!radioValue,
                  saveInto: local!radioValue,
                  /*choiceLayout: "COMPACT",*/
                  required: false()
                )
              ),
              a!sideBySideItem(
                width: "10X",
                item: a!richTextDisplayField(
                  value: a!richtextitem(
                    text: a!richtexticon(
                      caption: "Clear Radio Button Value",
                      icon: "REMOVE"
                    ),
                    link: a!dynamicLink(
                      saveInto: a!save(
                        local!radioValue,
                        null()
                      )
                    ),
                    linkStyle: "STANDALONE"
                  )
                )
              )
            }
          ),
          a!dropdownField(
            label: "Dropdown",
            choiceLabels: {"1", "2"},
            choiceValues: {"1", "2"},
            placeholderLabel: "(Standard Dropdown)"
          )
        }
      )
    )

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt
    That is an interesting solution Mike! Currently we are on Appian 17.3. We'll keep your approach in mind when we move over to Appian 18.x. Thanks a lot!
  • 0
    Certified Lead Developer
    in reply to snehab848
    Sorry to hear you don't have 18.1's features available to use yet. I would also like to point out that the only two features I've listed that you can't do in 17.3 (i believe) are the Side-By-Side Layout and Rich Text Icon. So if you wanted to do something similar, you could probably just use an image field right below the radio button field, and the for the image you could use the a!iconIndicator component (with the "REMOVE" icon), and a link configured in the same way. It wouldn't look QUITE as nice as my original version but it might be pretty good.
Reply
  • 0
    Certified Lead Developer
    in reply to snehab848
    Sorry to hear you don't have 18.1's features available to use yet. I would also like to point out that the only two features I've listed that you can't do in 17.3 (i believe) are the Side-By-Side Layout and Rich Text Icon. So if you wanted to do something similar, you could probably just use an image field right below the radio button field, and the for the image you could use the a!iconIndicator component (with the "REMOVE" icon), and a link configured in the same way. It wouldn't look QUITE as nice as my original version but it might be pretty good.
Children
No Data