{% extends 'form/partials/base_field.html' %}

{% load form_tags %}

{% block input %}

    <select 
        type="{{model_field.input_type}}"
        name="{{ field.name }}" 
        id="{{ field.auto_id }}" 
        class="field-type-{{model_field.type}}"

        {% block field_attributes %}{{block.super}}{% endblock %}
        
        {% if multiple %} multiple{% endif %}

        {% if model_field.placeholder_text %} 
        data-placeholder="{{model_field.placeholder_text|striptags|safe}}" 
        {% endif %}

    >

        {% if default_option %}<option value="">{{default_option}}</option>{% endif %}



        {% with model_field.get_choices as field_choices %}


        {% block options %}
        {% for x,y in field_choices %}
        
		    <option value="{{ x }}" 
            {% if multiple %}
            {% if x in field.value %}selected{% endif %}
            {% else %}
            {% if field.value|tostring == x|tostring %}selected{% endif %}
            {% endif %}
            >{{ y|safe }}</option>
		{% endfor %}
        {% endblock %}

        {% endwith %}
    </select>
{% endblock %}