{% load form_helpers %}

<div class="form-group{% if field.errors %} has-error{% endif %} {{ field.css_classes }}">
  {% if field|is_checkbox %}
    <div class="{{ classes.single_value }}">
      <div class="checkbox">
        {% if field.auto_id %}
          <label
            {% if field.field.required and form.required_css_class %}
            class="{{ form.required_css_class }}"
            {% endif %}>
            {{ field }}
            <span>{{ field.label }}</span>
            {% if field.help_text %}
            <span class="help-icon" data-toggle="tooltip"
              data-placement="top" title="{{ field.help_text|safe }}">
              <span class="glyphicon glyphicon-question-sign"></span>
            </span>
          {% endif %}
          </label>
        {% endif %}
        {% for error in field.errors %}
          <span class="help-block alert alert-danger {{ form.error_css_class }}">{{ error }}</span>
        {% endfor %}
      </div>
    </div>
  {% elif field|is_radio %}
    {% if field.auto_id %}
      <label class="control-label {{ classes.label }} {% if field.field.required %}{{ form.required_css_class }}{% endif %}">{{ field.label }}</label>
      {% if field.help_text %}
        <span class="help-icon" data-toggle="tooltip" data-placement="top" title="{{ field.help_text|safe }}"><span class="glyphicon glyphicon-question-sign"></span></span>
      {% endif %}
    {% endif %}
    <div class="{{ classes.value }}">
      {% for choice in field %}
        <div class="radio">
          <label>
            {{ choice.tag }}
            {{ choice.choice_label }}
          </label>
        </div>
      {% endfor %}

      {% for error in field.errors %}
        <span class="help-block alert alert-danger {{ form.error_css_class }}">{{ error }}</span>
      {% endfor %}

    </div>
  {% else %}
    {% if field.auto_id %}
      <label class="control-label {{ classes.label }} {% if field.field.required %}{{ form.required_css_class }}{% endif %}" for="{{ field.auto_id }}">{{ field.label }}</label>
      {% if field.help_text %}
        <span class="help-icon" data-toggle="tooltip" data-placement="top" title="{{ field.help_text|safe }}"><span class="glyphicon glyphicon-question-sign"></span></span>
      {% endif %}
    {% endif %}

    <div class="{{ classes.value }} {{ field|wrapper_classes }}">
      {{ field|add_bootstrap_class }}
      {% for error in field.errors %}
        <span class="help-block alert alert-danger {{ form.error_css_class }}">{{ error }}</span>
      {% endfor %}
    </div>
  {% endif %}
</div>
