Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / themes / contrib / bootstrap / templates / input / select.html.twig
1 {#
2 /**
3  * @file
4  * Theme override for a select element.
5  *
6  * Available variables:
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.
12  *
13  * @ingroup templates
14  *
15  * @see template_preprocess_select()
16  */
17 #}
18 {% spaceless %}
19   {% if input_group %}
20     <div class="input-group">
21   {% endif %}
22
23   {% if prefix %}
24     {{ prefix }}
25   {% endif %}
26
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
30    #}
31   {% if not attributes.offsetExists('multiple') %}
32     <div class="select-wrapper">
33   {% endif %}
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 %}
40               <option
41                 value="{{ sub_option.value }}"{{ sub_option.selected ? ' selected="selected"' }}>{{ sub_option.label }}</option>
42             {% endfor %}
43           </optgroup>
44         {% elseif option.type == 'option' %}
45           <option
46             value="{{ option.value }}"{{ option.selected ? ' selected="selected"' }}>{{ option.label }}</option>
47         {% endif %}
48       {% endfor %}
49     </select>
50   {% if not attributes.offsetExists('multiple') %}
51     </div>
52   {% endif %}
53
54   {% if suffix %}
55     {{ suffix }}
56   {% endif %}
57
58   {% if input_group %}
59     </div>
60   {% endif %}
61 {% endspaceless %}