{% extends 'forms/' ~ layout|default('field') ~ '.html.twig' %}

{% block input %}
    <select
            {# required attribute structures #}
            name="{{ (scope ~ name)|fieldName|e }}"
            {# global attribute structures #}
            {{ block('global_attributes') }}
            {# non-gloval attribute structures #}
            {% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
            {% if field.disabled in ['on', 'true', 1] %}disabled="disabled"{% endif %}
            {% if field.multiple in ['on', 'true', 1] %}multiple="multiple"{% endif %}
            {% if field.required in ['on', 'true', 1] %}required="required"{% endif %}
            {% if field.placeholder is defined %}data-placeholder="{{ field.placeholder|e }}"{% endif %}
            {% if field.size is defined %}size="{{ field.size|e }}"{% endif %}
            >

        {% block options %}
            {% for key, text in field.options %}
                <option
                        {# required attribute structures #}
                        {% if key|trim == value|trim %}selected="selected"{% endif %}
                        value="{{ key|e }}"
                        {# non-gloval attribute structures #}
                        {% if field.options.disabled in ['on', 'true', 1] %}disabled="disabled"{% endif %}
                        {% if field.options.label is defined %}label="{{ field.options.label|e }}"{% endif %}
                        >{{ text|e }}</option>
            {% endfor %}
        {% endblock %}
    </select>
    {% block reset_field %}{% endblock %}
{% endblock %}
