{% load util_tags %}

{% with type=field|field_type|upper type_checkbox='CHECKBOXSELECTMULTIPLE' type_radio='RADIOSELECT' %}
    <div class="form__field{% if label or type == type_checkbox or type == type_radio %} form__field--label{% endif %}">
        {% if label or type == type_checkbox or type == type_radio %}
            <label class="form__field__label" for="{{ field.id_for_label }}"><span>{{ field.label }}:</span></label>
        {% endif %}

        {% if type == type_checkbox or type == type_radio %}
            {% for value, text in field.field.choices %}
                <input type="{% if type == type_checkbox %}checkbox{% else %}radio{% endif %}"
                       value="{{ value }}" name="{{ field.name }}"
                       id="{{ field.auto_id }}_{{ forloop.counter0 }}">
                <label for="{{ field.auto_id }}_{{ forloop.counter0 }}">
                    <span class="form__field__choice__icon">
                        {% include 'project/assets/tick.svg' %}
                    </span>
                    {{ text }}
                </label>
            {% endfor %}
        {% else %}
            {{ field }}
        {% endif %}

        {% if field.errors %}
            <p class="form__field__errors">
                {% for error in field.errors %}
                    {{ error }}{% if not forloop.last %}<br>{% endif %}
                {% endfor %}
            </p>
        {% endif %}

        {% if field.help_text %}
            <p class="form__field__help_text">{{ field.help_text }}</p>
        {% endif %}
    </div>
{% endwith %}