Ticket #6630: form.html

File form.html, 1.3 KB (added by Mitar, 14 years ago)

A simple approach to fieldsets – example form template

Line 
1{% spaceless %}
2{% load i18n %}
3{% if form %}
4 {% if form.errors %}
5 <p class="errornote">{% blocktrans count form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}</p>
6 {{ form.non_field_errors }}
7 {% endif %}
8 {% if form.is_multipart %}
9 <form action="{{ form_action }}" method="post" enctype="multipart/form-data">
10 {% else %}
11 <form action="{{ form_action }}" method="post">
12 {% endif %}
13 {% csrf_token %}
14 {% for field in form.hidden_fields %}
15 {{ field }}
16 {% endfor %}
17 {% for field in form.visible_fields %}
18 {% ifchanged field.fieldset.name %}
19 {% if not forloop.first %}
20 </ul>
21 </fieldset>
22 {% endif %}
23 <fieldset>
24 {% if field.fieldset.name %}<legend>{{ field.fieldset.name }}</legend>{% endif %}
25 <ul>
26 {% endifchanged %}
27 <li{% if field.css_classes %} class="{{ field.css_classes }}"{% endif %}>
28 {{ field.errors }}
29 {{ field.label_tag }}: {{ field }}
30 {% if field.help_text %}<p class="help">{{ field.help_text }}</p>{% endif %}
31 </li>
32 {% if forloop.last %}
33 </ul>
34 </fieldset>
35 {% endif %}
36 {% endfor %}
37 <ul>
38 <li><input type="reset" value="Reset" /></li>
39 <li><input type="submit" value="{{ form_submit }}" /></li>
40 </ul>
41 </form>
42{% endif %}
43{% endspaceless %}
Back to Top