An input field that allows choosing between a set of predefined options.
var checkboxGroup = CardService.newSelectionInput() .setType(CardService.SelectionInputType.CHECK_BOX) .setTitle("A group of checkboxes. Multiple selections are allowed.") .setFieldName("checkbox_field") .addItem("checkbox one title", "checkbox_one_value", false) .addItem("checkbox two title", "checkbox_two_value", true) .addItem("checkbox three title", "checkbox_three_value", true) .setOnChangeAction(CardService.newAction() .setFunctionName("handleCheckboxChange")); var radioGroup = CardService.newSelectionInput() .setType(CardService.SelectionInputType.RADIO_BUTTON) .setTitle("A group of radio buttons. Only a single selection is allowed.") .setFieldName("checkbox_field") .addItem("radio button one title", "radio_one_value", true) .addItem("radio button two title", "radio_two_value", false) .addItem("radio button three title", "radio_three_value", false);
Methods
Method | Return type | Brief description |
---|---|---|
addItem(text, value, selected) | SelectionInput | Adds a new item that can be selected. |
setFieldName(fieldName) | SelectionInput | Sets the key that identifies this selection input in the event object that is generated when there is a UI interaction. |
setOnChangeAction(action) | SelectionInput | Sets an Action to be performed whenever the selection input changes. |
setTitle(title) | SelectionInput | Sets the title to be shown ahead of the input field. |
setType(type) | SelectionInput | Sets the type of this input. |
Detailed documentation
addItem(text, value, selected)
Adds a new item that can be selected.
Parameters
Name | Type | Description |
---|---|---|
text | Object | The text to be shown for this item. Non-string primitive arguments are converted to strings automatically. |
value | Object | The form input value that is sent via the callback. Non-string primitive arguments are converted to strings automatically. |
selected | Boolean | Whether the item should start as selected or unselected. |
Return
SelectionInput
— This object, for chaining.
setFieldName(fieldName)
Sets the key that identifies this selection input in the event object that is generated when there is a UI interaction. Not visible to the user. Required, must be unique.
Parameters
Name | Type | Description |
---|---|---|
fieldName | String | The name to assign to this input. |
Return
SelectionInput
— This object, for chaining.
setOnChangeAction(action)
Sets an Action
to be performed whenever the selection input changes.
Parameters
Name | Type | Description |
---|---|---|
action | Action | The action to take. |
Return
SelectionInput
— This object, for chaining.
setTitle(title)
Sets the title to be shown ahead of the input field.
Parameters
Name | Type | Description |
---|---|---|
title | String | The input field title. |
Return
SelectionInput
— This object, for chaining.
setType(type)
Sets the type of this input. Defaults to CHECKBOX
.
Parameters
Name | Type | Description |
---|---|---|
type | SelectionInputType | The selection type. |
Return
SelectionInput
— This object, for chaining.