Issue #2152225 by longwave, JeroenT, steveoliver, joelpittet, hussainweb, shanethehat, jenlampton, kpa, AnythonyR, EVIIILJ, kgoel, Cottser, dsdeiz, hanpersand: Convert theme_select() to Twig
2014-03-07 21:51:16 +00:00
|
|
|
{#
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Default theme implementation for a select element.
|
|
|
|
*
|
|
|
|
* Available variables:
|
|
|
|
* - attributes: HTML attributes for the select tag.
|
|
|
|
* - options: The option element children.
|
|
|
|
*
|
|
|
|
* @see template_preprocess_select()
|
|
|
|
*
|
|
|
|
* @ingroup themeable
|
|
|
|
*/
|
|
|
|
#}
|
2015-07-28 14:56:05 +00:00
|
|
|
{% 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 %}
|