select.html.twig
Same filename in this branch
Same filename in other branches
- 9 core/themes/stable9/templates/form/select.html.twig
- 9 core/themes/stable/templates/form/select.html.twig
- 9 core/themes/starterkit_theme/templates/form/select.html.twig
- 9 core/themes/classy/templates/form/select.html.twig
- 9 core/modules/system/templates/select.html.twig
- 10 core/themes/stable9/templates/form/select.html.twig
- 10 core/themes/starterkit_theme/templates/form/select.html.twig
- 10 core/modules/system/templates/select.html.twig
- 11.x core/themes/stable9/templates/form/select.html.twig
- 11.x core/themes/starterkit_theme/templates/form/select.html.twig
- 11.x core/modules/system/templates/select.html.twig
Theme override for a select element.
Available variables:
- attributes: HTML attributes for the <select> tag.
- options: The <option> element children.
See also
1 theme call to select.html.twig
- Select::getInfo in core/
lib/ Drupal/ Core/ Render/ Element/ Select.php - Returns the element properties for this element.
File
-
core/
themes/ classy/ templates/ form/ select.html.twig
View source
- {#
- /**
- * @file
- * Theme override for a select element.
- *
- * Available variables:
- * - attributes: HTML attributes for the <select> tag.
- * - options: The <option> element children.
- *
- * @see template_preprocess_select()
- */
- #}
- {% spaceless %}
- <select{{ attributes }}>
- {% for option in options %}
- {% if option.type == 'optgroup' %}
- <optgroup label="{{ option.label }}">
- {% for sub_option in option.options %}
- <option value="{{ sub_option.value }}"{{ sub_option.selected ? ' selected="selected"' }}>{{ sub_option.label }}</option>
- {% endfor %}
- </optgroup>
- {% elseif option.type == 'option' %}
- <option value="{{ option.value }}"{{ option.selected ? ' selected="selected"' }}>{{ option.label }}</option>
- {% endif %}
- {% endfor %}
- </select>
- {% endspaceless %}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.