Преглед изворни кода

Add new form.html template to make creating forms even easier

master
David Winterbottom пре 13 година
родитељ
комит
44a6f116e6

+ 1
- 5
oscar/templates/oscar/dashboard/catalogue/category_form.html Прегледај датотеку

@@ -28,9 +28,5 @@
28 28
 {% endblock header %}
29 29
 
30 30
 {% block dashboard_content %}
31
-	<form action="." class="wysiwyg" method="post" enctype="multipart/form-data">{% csrf_token %}
32
-		{{ form.as_p }}
33
-		<button type="submit" class="btn btn-primary btn-large">{% trans "Save" %}</button> {% trans "or" %}
34
-		<a href="{% url dashboard:catalogue-category-list %}">{% trans "cancel" %}</a>
35
-	</form>
31
+	{% include 'partials/form.html' with includes_files=1 class='wysiwyg' %}
36 32
 {% endblock dashboard_content %}

+ 1
- 1
oscar/templates/oscar/dashboard/vouchers/voucher_delete.html Прегледај датотеку

@@ -40,7 +40,7 @@
40 40
 		</tbody>
41 41
 	</table>
42 42
 
43
-	<form action="." method="post" class="">
43
+	<form action="." method="post" class="form-horizontal">
44 44
 		{% csrf_token %}
45 45
 		<div class="form-actions">
46 46
 			<button class="btn btn-danger btn-large" type="submit">{% trans "Delete" %}</button> {% trans "or" %}

+ 9
- 0
oscar/templates/oscar/partials/form.html Прегледај датотеку

@@ -0,0 +1,9 @@
1
+{% load i18n %}
2
+<form class="form-horizontal {{ class }}" method="{{ method|default:"post" }}" action="{{ action|default:"." }}" {% if includes_files %}enctype="multipart/form-data"{% endif %}>
3
+	{% if not method == "get" %}{% csrf_token %}{% endif %}
4
+	{% include 'partials/form_fields.html' %}
5
+	<div class="form-actions">
6
+		<button class="btn btn-large btn-primary" type="submit">{% trans "Save" %}</button>
7
+		{% trans "or" %} <a href="#" onclick="history.go(-1);return false" >{% trans "cancel" %}</a>
8
+	</div>
9
+</form>

+ 4
- 1
oscar/templates/oscar/partials/form_field.html Прегледај датотеку

@@ -1,6 +1,9 @@
1 1
 {% load form_tags %}
2 2
 
3
-{# Make the field widget type available to templates #}
3
+{% comment %}
4
+Make the field widget type available to templates so we can mark-up
5
+checkboxes differently to other widgets.
6
+{% endcomment %}
4 7
 {% annotate_form_field field %}
5 8
 
6 9
 <div class="control-group {% for error in field.errors %}error{% endfor %}">

+ 4
- 0
oscar/templates/oscar/partials/form_fields.html Прегледај датотеку

@@ -1,4 +1,8 @@
1 1
 <span class="help-block">{{ form.non_field_errors }}</span>
2 2
 {% for field in form %}
3
+	{% comment %} 
4
+	We use a separate template for each field so that forms can be rendered
5
+	field-by-field easily #}
6
+	{% endcomment %}
3 7
 	{% include 'partials/form_field.html' with field=field %}
4 8
 {% endfor %}

+ 1
- 0
oscar/templates/oscar/partials/form_fields_inline.html Прегледај датотеку

@@ -1,3 +1,4 @@
1
+<span class="help-block">{{ form.non_field_errors }}</span>
1 2
 {% for field in form %}
2 3
     {% if field.is_hidden %}
3 4
         {{ field }}

Loading…
Откажи
Сачувај