summaryrefslogtreecommitdiff
path: root/horizon/templates/horizon/common/_form_field.html
blob: c521fc0d6ee4a9bca61720274e42ec128e053189 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{% 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>