How to allow a checkbox to create a greyed out/disabled field

Hi everyone,

 

This may be a simple fix, but I cannot get it right. I have created a form where the user can input their SSN. If they do not have a SSN, they have to check a checkbox and the field for Social security number should become greyed out/disabled but that is not working currently. I am only able to make the field null. Currently, these are the relevant pieces of my code:

rule!AF_CMPT_General_booleanCheckBoxField(
choiceLabel: "I don't have an SSN",
choiceValue: {
true
},
value: local!checkbox,
saveInto: {
local!checkbox
}
),

}
),

rule!AF_CMPT_General_textField(
label: cons!SOCIAL_SECURITY_LABEL,
readOnly: if(
isnull(
local!checkbox
),
false,
true
), 
value: 
if(
isnull(
local!checkbox 
),
ri!boardUser.socialSecurityNumber,
{}
)

The {} is where the number currently is blank if the user checks the "I don't have an ssn" checkbox.

 

Any help would be appreciated.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi dcuser12 Also you can have a look into this sample code for your requirement, where the SSN field gets disabled and empty when a user click on the Checkbox.

    load(
      local!checkbox,
      local!SSN,
      a!formLayout(
        label: "Test Form",
        contents: {
          a!textField(
            label: "SSN",
            value: local!SSN,
            saveInto: local!SSN,
            disabled: if(
              not(isnull(local!checkbox)),
              local!checkbox,
              false()
            )
          ),
          a!checkboxField(
            choiceLabels: {"I don't have SSN"},
            choiceValues: {true()},
            value: local!checkbox,
            saveInto: {
              local!checkbox,
              a!save(local!SSN, null())
            }
          )
        }
      )
    )

    Hope this will help you

Reply
  • 0
    Certified Lead Developer

    Hi dcuser12 Also you can have a look into this sample code for your requirement, where the SSN field gets disabled and empty when a user click on the Checkbox.

    load(
      local!checkbox,
      local!SSN,
      a!formLayout(
        label: "Test Form",
        contents: {
          a!textField(
            label: "SSN",
            value: local!SSN,
            saveInto: local!SSN,
            disabled: if(
              not(isnull(local!checkbox)),
              local!checkbox,
              false()
            )
          ),
          a!checkboxField(
            choiceLabels: {"I don't have SSN"},
            choiceValues: {true()},
            value: local!checkbox,
            saveInto: {
              local!checkbox,
              a!save(local!SSN, null())
            }
          )
        }
      )
    )

    Hope this will help you

Children
No Data