form.html 1.21 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
{% csrf_token %}
{% if form.non_field_errors %}
  {% if form_error_title %}<h4 class="alert-heading">{{ form_error_title }}</h4>{% endif %}
  {% for error_message in form.non_field_errors %}
    <div class="alert alert-block alert-error">
      {{ error_message }}
    </div>    
  {% endfor %}
{% endif %}

{% for field in form %}

  {% if field.is_hidden %}
    {{ field }}
  {% else %}
Tom Giannattasio committed
16

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
  <div id="div_{{ field.auto_id }}" class="clearfix control-group{% if field.errors %} error{% endif %}">
    {% if field.label %}
      <label for="{{ field.id_for_label }}" class="control-label {% if field.field.required %}requiredField{% endif %}">
      {{ field.label|safe }}
      </label>
    {% endif %}
    <div class="controls">
      {{ field }} {% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
      {% if field.errors %}
        {% for error in field.errors %}
          <div id="error_{{ forloop.counter }}_{{ field.auto_id }}" class="help-block"><strong>{{ error }}</strong></div>
        {% endfor %}
      {% endif %}
      {% if field.help_text %}
        <p id="hint_{{ field.auto_id }}" class="help-block">{{ field.help_text|safe }}</p>
      {% endif %}
    </div>
  </div>
  {% endif %}

{% endfor %}