Radio Button Component

Radio Buttons

Function: a!radioButtonField()

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

If the choice is not exclusive, then consider using checkboxes or a multiple dropdown component.

If there are many choices, make the component as large as necessary to display all the options. If a more compact presentation is desirable, consider using a dropdown component.

Parameters

Name Keyword Types Description

Label

label

Text

Text to display as the field label.

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.

Display Value

value

Any Type

Value of 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.

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.

Choice Layout

choiceLayout

Text

Determines the layout. Valid values: "STACKED" (default), "COMPACT".

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

  • Choices display in the same order as defined in the Choice Labels parameter. The Choice Labels argument cannot be null.
  • If null is passed to Selected Value, none of the options are selected. It is a best practice for radio button components to always have a default 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.

Editable Radio Button with First Choice Selected by Default

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
=a!localVariables(
  local!browser: "ffx",
  a!radioButtonField(
    label: "Browser",
    choiceLabels: {
      "Firefox",
      "Chrome",
      "Safari"
    },
    choiceValues: {
      "ffx",
      "chr",
      "sfr"
    },
    value: local!browser,
    saveInto: local!browser
  )
)

Displays the following:

Open in Github Built: Fri, Mar 11, 2022 (04:59:07 PM)

On This Page

FEEDBACK