{% load aldryn_forms_tags i18n %}

{% if field %}
    <div class="checkbox{% if field.field.required %} form-required{% endif %}{% if field.errors %} has-error{% endif %}" data-required_min="{{ instance.min_value }}" data-required_max="{{ instance.max_value }}">
        {% block form_field_label %}
            <p>
                {{ field.label }}
                {% if field.field.required %}
                    <abbr title="{% trans "Required field" %}">*</abbr>
                {% endif %}
            </p>
        {% endblock form_field_label %}
        {% block form_field %}
            {% for choice in field.field.choices %}
                <label>
                    <input type="checkbox" value="{{ choice.0 }}" name="{{ field.name }}" id="field-{{ choice.0 }}"
                        {% if choice.0|force_text in field.value|force_text_list %} checked="checked"{% endif %}>
                    {{ choice.1 }}
                </label>
            {% endfor %}
        {% endblock form_field %}
        {% block form_field_errors %}
            {% if field.errors %}
                {% for error in field.errors %}
                    <span class="text-danger">{{ error }}</span>
                {% endfor %}
            {% endif %}
        {% endblock form_field_errors %}
        {% block form_field_help_text %}
            {% if field.help_text %}
                <p class="help-block">{{ field.help_text }}</p>
            {% endif %}
        {% endblock form_field_help_text %}
    </div>
{% endif %}
