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
Hi,
Yes you can't deselect the ration button option once selected, you can add a new option e,g, None. along with the other options
and Appian don't allow to disable the options in CheckBox
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)" ) } ) )
Hi snehab848
You can try following approach
load( local!optionChosen, { a!richTextDisplayField( label: "Choose an option", value: { a!richTextIcon( icon: if( local!optionChosen = "Option 1", "dot-circle-o", "circle-o" ), link: a!dynamicLink( value: "Option 1", saveInto: a!save( local!optionChosen, if( local!optionChosen = save!value, null, save!value ) ) ), color: "SECONDARY", linkStyle: "STANDALONE" ), a!richTextItem( text: " Option 1" ) } ), a!richTextDisplayField( value: { a!richTextIcon( icon: if( local!optionChosen = "Option 2", "dot-circle-o", "circle-o" ), link: a!dynamicLink( value: "Option 2", saveInto: a!save( local!optionChosen, if( local!optionChosen = save!value, null, save!value ) ) ), color: "SECONDARY", linkStyle: "STANDALONE" ), a!richTextItem( text: " Option 2" ) } ) } )