form-options-attributes--select--options-attributes.html.twig in Form Options Attributes 8
{% apply 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"' }} {{ options_attributes[option.label][sub_option.value] }}>{{ sub_option.label }}</option>
{% endfor %}
</optgroup>
{% elseif option.type == 'option' %}
<option value="{{ option.value }}"{{ option.selected ? ' selected="selected"' }} {{ options_attributes[option.value] }}>{{ option.label }}</option>
{% endif %}
{% endfor %}
</select>
{% endapply %}
File
templates/form-options-attributes--select--options-attributes.html.twig
View source
- {% apply 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"' }} {{ options_attributes[option.label][sub_option.value] }}>{{ sub_option.label }}</option>
- {% endfor %}
- </optgroup>
- {% elseif option.type == 'option' %}
- <option value="{{ option.value }}"{{ option.selected ? ' selected="selected"' }} {{ options_attributes[option.value] }}>{{ option.label }}</option>
- {% endif %}
- {% endfor %}
- </select>
- {% endapply %}