Select ====== .. granite:servercomponent:: /libs/granite/ui/components/foundation/form/select :supertype: /libs/granite/ui/components/foundation/form/field Select is a component to represent a concept of selection of some options. It extends :granite:servercomponent:`Field ` component. It has the following content structure: .. gnd:gnd:: [granite:FormSelect] > granite:FormField /** * The id attribute. */ - id (String) /** * The class attribute. This is used to indicate the semantic relationship of the component similar to ``rel`` attribute. */ - rel (String) /** * The class attribute. */ - class (String) /** * The title attribute. */ - title (String) i18n /** * The name that identifies the field when submitting the form. */ - name (String) /** * The initial text to display when nothing is selected. */ - emptyText (String) i18n /** * Indicates if the field is in disabled state. */ - disabled (Boolean) /** * Indicates if the field is mandatory to be filled. */ - required (Boolean) /** * The name of the validator to be applied. E.g. ``foundation.jcr.name``. * See :doc:`validation ` in Granite UI. */ - validation (String) multiple /** * Indicates if the user is able to select multiple selections. */ - multiple (Boolean) /** * ``true`` to translate the options, ``false`` otherwise. */ - translateOptions (Boolean) = true /** * ``true`` to sort the options based on the text, ``false`` otherwise. * * It is assumed that the options don't contain option group. */ - ordered (Boolean) = false /** * ``true`` to also add an empty option; ``false`` otherwise. * * Empty option is an option having both value and text equal to empty string. */ - emptyOption (Boolean) = false /** * ``true`` to generate the `SlingPostServlet @Delete `_ hidden input based on the field name. */ - deleteHint (Boolean) = true The options of the select are specified using :ref:`ItemDataSource `. Each option has the following structure: .. gnd:gnd:: [granite:FormSelectItem] /** * The id attribute. */ - id (String) /** * The class attribute. This is used to indicate the semantic relationship of the component similar to ``rel`` attribute. */ - rel (String) /** * The class attribute. */ - class (String) /** * The title attribute. */ - title (String) i18n /** * The value of the option. */ - value (StringEL) mandatory /** * Indicates if the option is in disabled state. */ - disabled (Boolean) /** * ``true`` to pre-select this option, ``false`` otherwise. */ - selected (Boolean) /** * The text of the option. */ - text (String) i18n Example:: + myselect - sling:resourceType = "granite/ui/components/foundation/form/select" - emptyText = "Select" - name = "myselect" + items + option1 - text = "op1" + option2 - text = "op2"