Choice

Choice

A Choice, when added to a Field becomes an option in an HTML select list or checkbox group.

Constructor

new Choice(value, label, selected)

Parameters:
Name Type Description
value string

The value of the choice/option.

label string

The label to be displayed to the user for this choice/option.

selected boolean

A boolean flag to indicate whether this choice/option should be selected when the HTML form control is rendered.

Source:

Methods

(static) makeList(items, selected, includeEmptyFirstOption)

Returns a list of choice objects.

Parameters:
Name Type Description
items Array.<(string|object)>

A list of items from which to make Choices. If each item is a string, both the value and label of the Choice will be set to the string. If the items are objects, the label of each Choice will be set to object.name and the value will be set to object.id. (This is because all PersistentObjects in DART include a name and id.)

selected string | Array.<string>

The item or items in the Choice list to be pre-selected when the HTML element renders. If this is a string, the first Choice whose value matches will be selected. If this is an array, all Choices whose values match items in the selected list will be selected.

includeEmptyFirstOption boolean

If true, makeList will add an empty first Choice to the beginning of the list it returns. That empty Choice will have label and value set to the empty string ''.

Source: