{% load crispy_forms_field %}

{% if field.is_hidden %}
    {{ field }}
{% else %}
    <div id="div_{{ field.auto_id }}" class="holder{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if field.errors and form_show_errors %} callout alert{% endif %}{% if field|is_checkbox %} checkbox{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">{% spaceless %}

        {% if field.label %}
            <div class="{{ switch_class }}">
                {% if field|is_checkbox %}
                    {% crispy_field field %}
                {% endif %}

                <label class="switch-paddle{% if field.errors and form_show_errors %} is-invalid-label{% endif %}{% if field.field.required %} required{% endif %}" for="{{ field.id_for_label }}">
                    <span class="show-for-sr">{{ field.label|safe }}{% if field.field.required %}<span class="asterisk">*</span>{% endif %}</span>
                </label>
            </div>
        {% endif %}

        {% if field|is_checkboxselectmultiple %}
            {% include 'foundation-6/layout/checkboxselectmultiple.html' %}
        {% endif %}

        {% if not field|is_checkbox and not field|is_checkboxselectmultiple %}
            {% crispy_field field %}
        {% endif %}

        {% if form_show_errors %}
            {% for error in field.errors %}
            <span id="error_{{ forloop.counter }}_{{ field.auto_id }}" class="form-error is-visible">
                {{ error }}
            </span>
            {% endfor %}
        {% endif %}

        {% if field.help_text %}
            <p id="helptext_{{ field.auto_id }}" class="help-text">{{ field.help_text|safe }}</p>
        {% endif %}
    {% endspaceless %}</div>
{% endif %}
