Dropdown Component

Function: a!dropdownField()

Displays a limited set of exclusive choices from which the user must select one item and saves a value based on the selected choice. To save the index of the choice instead of a value, use dropdown by index.

If the user may select none, one, or many of the choices, then consider using checkboxes or a multiple dropdown.

If there aren't many choices and users would benefit from easily seeing them all at once, consider using radio buttons.

Parameters

Name Keyword Types Description

Label

label

Text

Text to display as the field label.

Label Position

labelPosition

Text

Determines where the label appears. Valid values:

  • "ABOVE" (default) Displays the label above the component.
  • "ADJACENT" Displays the label to the left of the component.
  • "COLLAPSED" Hides the label. The label will still be read by screen readers; see accessibility considerations for more information.
  • "JUSTIFIED" Aligns the label alongside the component starting at the edge of the page.

Instructions

instructions

Text

Supplemental text about this field.

Required

required

Boolean

Determines if a value is required to submit the form. Default: false.

Disabled

disabled

Boolean

Determines if the field should display as potentially editable but grayed out. Default: false.

Choice Labels

choiceLabels

List of Text String

Array of options for the user to select.

Choice Values

choiceValues

List of Variant

Array of values associated with the available choices.

Placeholder Label

placeholderLabel

Text

Text to display when nothing is selected and the value is null.

Display Value

value

Any Type

Value of the choice to display as selected.

Validations

validations

List of Text String

Validation errors to display below the field when the value is not null.

Save Input To

saveInto

List of Save

One or more variables that are updated with the choice value when the user changes the selection. Use a!save() to save a modified or alternative value to a variable.

Validation Group

validationGroup

Text

When present, this field is only validated when a button in the same validation group is pressed. See the documentation for more information about how to use validation groups.

Required Message

requiredMessage

Text

Custom message to display when the field's value is required and not provided.

Help Tooltip

helpTooltip

Text

Displays a help icon with the specified text as a tooltip. The tooltip displays a maximum of 500 characters. The help icon does not show when the label position is "COLLAPSED".

Accessibility Text

accessibilityText

Text

Additional text to be announced by screen readers. Used only for accessibility; produces no visible change.

Visibility

showWhen

Boolean

Determines whether the component is displayed on the interface. When set to false, the component is hidden and is not evaluated. Default: true.

Notes

  • If you set Label Position to "ADJACENT" or "ABOVE", but do not give a value for Label, a space still displays to the left-side or above, respectively, of the component as if there was a label displayed. To ensure the component appears to the far left when Label has no value, use "COLLAPSED" for Label Position.
  • Choices display in the same order as defined in the Choice Labels parameter. The Choice Labels argument cannot be null.
  • Passing a null value to the dropdown's Selected Value parameter causes the placeholder text to appear selected. The Placeholder Label and Selected Value arguments cannot both be null. If the placeholder is selected and Required is true when a validating button is clicked, the field prompts the user to select a value.
  • Choice Labels and Choice Values must be the same length.
  • Choice Values cannot contain nulls or duplicate values.

Examples

Copy and paste an example into the INTERFACE DEFINITION in EXPRESSION MODE to see it displayed.

Disabled Dropdown with Label Displayed Above

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
=a!dropdownField(
  label: "Language",
  labelPosition: "ABOVE",
  instructions: "In which language are you most proficient?",
  choiceLabels: {
    "English",
    "Spanish",
    "French",
    "German"
  },
  choiceValues: {
    "en_US",
    "es_ES",
    "fr_FR",
    "de_DE"
  },
  value: "en_US",
  disabled: true
)

Displays the following:

Editable Dropdown with the First Choice Selected by Default

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
=a!localVariables(
  local!language: "en_US",
  a!dropdownField(
    label: "Language",
    instructions: "In which language are you most proficient?",
    choiceLabels: {
      "English",
      "Spanish",
      "French",
      "German"
    },
    choiceValues: {
      "en_US",
      "es_ES",
      "fr_FR",
      "de_DE"
    },
    value: local!language,
    saveInto: local!language
  )
)

Displays the following:

Dropdown with a Blank Choice Selected by Default

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
=a!localVariables(
  local!language: null,
  a!dropdownField(
    label: "Language",
    instructions: "In which language are you most proficient?",
    choiceLabels: {
      "English",
      "Spanish",
      "French",
      "German"
    },
    placeholderLabel: "Select a language...",
    choiceValues: {
      "en_US",
      "es_ES",
      "fr_FR",
      "de_DE"
    },
    value: local!language,
    saveInto: local!language
  )
)

Displays the following:

The following patterns include usage of the Dropdown Component.

FEEDBACK