Skip to main content
nicholaso0002
Known Participant
Oct 20, 2022 7:55 PM UTC
Solved

How do you remove the White Space on a DropdownField Component

How do you remove the White Space on a DropdownField Component

    csteward
    cstewardAnswer
    Brainy
    Oct 20, 2022 8:05 PM UTC

    The only other option is to allow a placeholder initially, but null it out if the user makes a selection (blocking them from de-selecting it essentially), thus you could not utilize this for optional fields.

    a!localVariables(
      local!options: {"a","b","c"},
      local!selected,
      
      a!dropdownField(
        label: "Dropdown",
        placeholder: if(rule!APN_isBlank(local!selected),"-- Select --",null),
        choiceLabels: local!options,
        choiceValues: local!options,
        value: local!selected,
        saveInto: local!selected
      )
    )

    4 replies

    mikes0011
    Brainy
    Oct 20, 2022 8:03 PM UTC

    As long as you have a Placeholder, that will appear there.  You could always remove the placeholder, but that would mean the dropdown would always have to have a value, and would display an error if its value is null.

    The Expression Guru
    nicholaso0002
    Known Participant
    Oct 20, 2022 8:44 PM UTC

    This also worked.

    csteward
    cstewardAnswer
    Brainy
    Oct 20, 2022 8:05 PM UTC

    The only other option is to allow a placeholder initially, but null it out if the user makes a selection (blocking them from de-selecting it essentially), thus you could not utilize this for optional fields.

    a!localVariables(
      local!options: {"a","b","c"},
      local!selected,
      
      a!dropdownField(
        label: "Dropdown",
        placeholder: if(rule!APN_isBlank(local!selected),"-- Select --",null),
        choiceLabels: local!options,
        choiceValues: local!options,
        value: local!selected,
        saveInto: local!selected
      )
    )

    nicholaso0002
    Known Participant
    Oct 20, 2022 8:42 PM UTC

    Thanks this worked for me.