4 * Theme override for a select element.
7 * - attributes: HTML attributes for the select tag.
8 * - input_group: Flag to display as an input group.
9 * - options: The option element children.
10 * - prefix: Markup to display before the input element.
11 * - suffix: Markup to display after the input element.
15 * @see template_preprocess_select()
20 <div class="input-group">
27 {# Browsers do not recognize pseudo :after selectors, we must create a wrapper
28 # around the select element to style it properly.
29 # @see http://stackoverflow.com/q/21103542
31 {% if not attributes.offsetExists('multiple') %}
32 <div class="select-wrapper">
34 {% set classes = ['form-control'] %}
35 <select{{ attributes.addClass(classes) }}>
36 {% for option in options %}
37 {% if option.type == 'optgroup' %}
38 <optgroup label="{{ option.label }}">
39 {% for sub_option in option.options %}
41 value="{{ sub_option.value }}"{{ sub_option.selected ? ' selected="selected"' }}>{{ sub_option.label }}</option>
44 {% elseif option.type == 'option' %}
46 value="{{ option.value }}"{{ option.selected ? ' selected="selected"' }}>{{ option.label }}</option>
50 {% if not attributes.offsetExists('multiple') %}