{% 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 }}">
    {% include 'horizon/common/fields/_themable_checkbox.html' %}
    </div>
  {% elif field|is_radio %}
    {% include 'horizon/common/fields/_themable_radiobutton.html' %}
  {% else %}
    {% if field.auto_id %}
      <label class="control-label {{ classes.label }} {% if field.field.required %}{{ form.required_css_class }}{% endif %}" for="{{ field.auto_id }}">
          <span class="field-label">{{ field.label }}</span></label>
      {% include "horizon/common/_form_field_decorator.html" %}
    {% endif %}

    <div class="{{ classes.value }} {{ field|wrapper_classes }}">
      {% with add_item_link=field|add_item_url %}
      {% if add_item_link %}
        <div class='input-group'>
          {{ field|add_bootstrap_class }}
          <span class="input-group-btn">
            <a href="{{ add_item_link }}" data-add-to-field="{{ field.auto_id }}" class='btn btn-default ajax-add ajax-modal'>
              <span class="fa fa-plus"></span>
            </a>
          </span>
        </div>
      {% else %}
        {% if field|is_number %}
          {% include 'horizon/common/fields/_themable_spinner.html' %}
        {% else %}
          {{ field|add_bootstrap_class }}
        {% endif %}
      {% endif %}
      {% endwith %}
    </div>
  {% endif %}
  {% for error in field.errors %}
    <span class="help-block {{ form.error_css_class }}">{{ error }}</span>
  {% endfor %}
</div>
