How to hide text input using radio button?

Hi everyone,

                 Can anyone help me out with this scenario:When clicking on the radio button i need to hide the below text input?

  Discussion posts and replies are publicly visible

  • store the selection in rule input and use same variable as a parameter for showWhen in textField... use whole sail code in with(). refer below code,
    contents: {
    a!radioButtonField(
    label: "Test",
    choiceLabels: {
    "Yes",
    "No"
    },
    choiceValues: {
    true(),
    false()
    },
    value: ri!flag,
    saveInto: ri!flag
    ),
    a!textField(
    label: "Lorem Ipsum",
    labelPosition: "ABOVE",
    showWhen: ri!flag
    )
    }

    Hope this will help you.
  • One solution is that you can have the value of the "masked" keyword in a!textfield() equal to the boolean (or the inverse of the boolean) that is being set with the radio button.
  • 0
    Certified Lead Developer
    Sorry, there's really no way to answer your question without a bit more detail behind what you need to do.
  • It seems like the showWhen parameter on whatever text input field you are using is the best solution, like annap suggested, assuming you want to hide the whole field. However if you really want to hide the text input and not the entire field then you should set the value to some conditional statement.

    Here is annap's code modified to do this instead.

    contents: {
    a!radioButtonField(
    label: "Test",
    choiceLabels: {
    "Yes",
    "No"
    },
    choiceValues: {
    true(),
    false()
    },
    value: ri!flag,
    saveInto: ri!flag
    ),
    a!textField(
    label: "Lorem Ipsum",
    labelPosition: "ABOVE",
    value: if (
    ri!flag,
    "",
    ri!textValue),
    ),
    saveInto: if (

    ri!flag,

    {},

    ri!textValue)
    }

    This is a bit odd though. I'm not sure that you would want to do this. As Mike said, more detail would help.

  • 0
    Certified Lead Developer
    Hi do you want to hide the text input or the complete text field?

    1. If you want to hide only text input in that case, you can have an another approach as well, apart from as suggested above:

    Let's say, you have a local variable local!choice_bool which captures radio button input as true or false, now declare a variable, let's say, local!placeholder
    Now you can configure your text field value as

    value:
    if (local!choice_bool=true(), local!placeholder, ri!myTextInput)
    saveInto : ri!myTextInput
    Here ri!myTextInput is the actual variable where you Text field value will be stored (if Any)

    2. If you want to hide complete Text field then configure following

    showWhen: not(local!choice_bool)

    Which indicates, when choice_bool is not true or false then display this field

    Make sure to define local!choice_bool either on load or as rule input, the default value for it should be false

    Hope this will help you.