camaleon-8.x-1.x-dev/templates/form/select.html.twig
templates/form/select.html.twig
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | {# /** * @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 %} |