{% load widget_tweaks backoffice_filters %}
{% if form.errors %}
<div class="alert alert-danger">
    {{ form|inline_errors|pretty_join }}
</div>
{% endif %}

{% if wrap_in_div_with_class %}
<div class="{{ wrap_in_div_with_class }}">
{% endif %}

{% for field in form.visible_fields %}
    <div class="form-group {% if forloop.last %}last{% endif %} {% if field.errors %}has-error{% endif %}">
        <label for="{{ field.auto_id }}" class="col-md-3 control-label">{{ field.label }}</label>

        <div class="col-md-9">
            {{ field|add_class:"form-control" }}
            {% if field.help_text %}<span class="help-block">{{ field.help_text }}</span>{% endif %}
        </div>
    </div>
{% endfor %}
{% for field in form.hidden_fields %}
    {{ field }}
{% endfor %}

{% if wrap_in_div_with_class %}
</div>
{% endif %}
