Select

/libs/granite/ui/components/foundation/form/select

Select is a component to represent a concept of selection of some options.

It extends Field component.

It has the following content structure:

granite:FormSelect
  1. granite:FormField
idstring

The id attribute.

relstring

The class attribute. This is used to indicate the semantic relationship of the component similar to rel attribute.

classstring

The class attribute.

titlestring
i18n

The title attribute.

namestring

The name that identifies the field when submitting the form.

emptyTextstring
i18n

The initial text to display when nothing is selected.

disabledboolean

Indicates if the field is in disabled state.

requiredboolean

Indicates if the field is mandatory to be filled.

validationstring
multiple

The name of the validator to be applied. E.g. foundation.jcr.name. See validation in Granite UI.

multipleboolean

Indicates if the user is able to select multiple selections.

translateOptionsboolean
  1. true

true to translate the options, false otherwise.

orderedboolean
  1. false

true to sort the options based on the text, false otherwise.

It is assumed that the options don’t contain option group.

emptyOptionboolean
  1. false

true to also add an empty option; false otherwise.

Empty option is an option having both value and text equal to empty string.

deleteHintboolean
  1. true

true to generate the SlingPostServlet @Delete hidden input based on the field name.

The options of the select are specified using ItemDataSource.

Each option has the following structure:

granite:FormSelectItem
idstring

The id attribute.

relstring

The class attribute. This is used to indicate the semantic relationship of the component similar to rel attribute.

classstring

The class attribute.

titlestring
i18n

The title attribute.

valuestringel
mandatory

The value of the option.

disabledboolean

Indicates if the option is in disabled state.

selectedboolean

true to pre-select this option, false otherwise.

textstring
i18n

The text of the option.

Example:

+ myselect
  - sling:resourceType = "granite/ui/components/foundation/form/select"
  - emptyText = "Select"
  - name = "myselect"
  + items
    + option1
      - text = "op1"
    + option2
      - text = "op2"