{% load form_helpers %}

<div class="form-group{% if field.errors %} has-error{% endif %} {{ field.css_classes }}">
  <label class="control-label col-sm-3" for="{{ field.id_for_label }}">{{ field.label }}
    {% if field.field.required %}{% include "horizon/common/_form_field_required.html" %}{% endif %}
  </label>
  <div class="col-sm-9 {{ classes.value }} {{ field|wrapper_classes }}">
    {% if field|is_checkbox %}
      {% with is_vertical=1 %}
      {% include 'horizon/common/fields/_themable_checkbox.html' %}
      {% endwith %}
    {% else %}
      {{ field|add_bootstrap_class }}
    {% endif %}
    {% for error in field.errors %}
      <span class="help-block {{ form.error_css_class }}">{{ error }}</span>
    {% empty %}
      {% comment %}
      Escape help_text a second time here, to avoid an XSS issue in bootstrap.js.
      This can most likely be removed once we upgrade bootstrap.js past 2.0.2.
      Note: the spaces are necessary here.
      {% endcomment %}
      {% if field.help_text %}
        <span class="help-block">{% filter force_escape %} {{ field.help_text }} {% endfilter %} </span>
      {% endif %}
    {% endfor %}
  </div>
</div>
