mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #32339 -- Added div.html form template.
This commit is contained in:
committed by
Carlton Gibson
parent
27b07a3246
commit
ec5659382a
@@ -66,6 +66,7 @@ class BaseForm(RenderableFormMixin):
|
||||
prefix = None
|
||||
use_required_attribute = True
|
||||
|
||||
template_name_div = "django/forms/div.html"
|
||||
template_name_p = "django/forms/p.html"
|
||||
template_name_table = "django/forms/table.html"
|
||||
template_name_ul = "django/forms/ul.html"
|
||||
|
||||
@@ -63,6 +63,7 @@ class BaseFormSet(RenderableFormMixin):
|
||||
),
|
||||
}
|
||||
|
||||
template_name_div = "django/forms/formsets/div.html"
|
||||
template_name_p = "django/forms/formsets/p.html"
|
||||
template_name_table = "django/forms/formsets/table.html"
|
||||
template_name_ul = "django/forms/formsets/ul.html"
|
||||
|
||||
24
django/forms/jinja2/django/forms/div.html
Normal file
24
django/forms/jinja2/django/forms/div.html
Normal file
@@ -0,0 +1,24 @@
|
||||
{{ errors }}
|
||||
{% if errors and not fields %}
|
||||
<div>{% for field in hidden_fields %}{{ field }}{% endfor %}</div>
|
||||
{% endif %}
|
||||
{% for field, errors in fields %}
|
||||
<div{% set classes = field.css_classes() %}{% if classes %} class="{{ classes }}"{% endif %}>
|
||||
{% if field.use_fieldset %}
|
||||
<fieldset>
|
||||
{% if field.label %}{{ field.legend_tag() }}{% endif %}
|
||||
{% else %}
|
||||
{% if field.label %}{{ field.label_tag() }}{% endif %}
|
||||
{% endif %}
|
||||
{% if field.help_text %}<div class="helptext">{{ field.help_text|safe }}</div>{% endif %}
|
||||
{{ errors }}
|
||||
{{ field }}
|
||||
{% if field.use_fieldset %}</fieldset>{% endif %}
|
||||
{% if loop.last %}
|
||||
{% for field in hidden_fields %}{{ field }}{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if not fields and not errors %}
|
||||
{% for field in hidden_fields %}{{ field }}{% endfor %}
|
||||
{% endif %}
|
||||
1
django/forms/jinja2/django/forms/formsets/div.html
Normal file
1
django/forms/jinja2/django/forms/formsets/div.html
Normal file
@@ -0,0 +1 @@
|
||||
{{ formset.management_form }}{% for form in formset %}{{ form.as_div() }}{% endfor %}
|
||||
24
django/forms/templates/django/forms/div.html
Normal file
24
django/forms/templates/django/forms/div.html
Normal file
@@ -0,0 +1,24 @@
|
||||
{{ errors }}
|
||||
{% if errors and not fields %}
|
||||
<div>{% for field in hidden_fields %}{{ field }}{% endfor %}</div>
|
||||
{% endif %}
|
||||
{% for field, errors in fields %}
|
||||
<div{% with classes=field.css_classes %}{% if classes %} class="{{ classes }}"{% endif %}{% endwith %}>
|
||||
{% if field.use_fieldset %}
|
||||
<fieldset>
|
||||
{% if field.label %}{{ field.legend_tag }}{% endif %}
|
||||
{% else %}
|
||||
{% if field.label %}{{ field.label_tag }}{% endif %}
|
||||
{% endif %}
|
||||
{% if field.help_text %}<div class="helptext">{{ field.help_text|safe }}</div>{% endif %}
|
||||
{{ errors }}
|
||||
{{ field }}
|
||||
{% if field.use_fieldset %}</fieldset>{% endif %}
|
||||
{% if forloop.last %}
|
||||
{% for field in hidden_fields %}{{ field }}{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if not fields and not errors %}
|
||||
{% for field in hidden_fields %}{{ field }}{% endfor %}
|
||||
{% endif %}
|
||||
1
django/forms/templates/django/forms/formsets/div.html
Normal file
1
django/forms/templates/django/forms/formsets/div.html
Normal file
@@ -0,0 +1 @@
|
||||
{{ formset.management_form }}{% for form in formset %}{{ form.as_div }}{% endfor %}
|
||||
@@ -73,6 +73,10 @@ class RenderableFormMixin(RenderableMixin):
|
||||
"""Render as <li> elements excluding the surrounding <ul> tag."""
|
||||
return self.render(self.template_name_ul)
|
||||
|
||||
def as_div(self):
|
||||
"""Render as <div> elements."""
|
||||
return self.render(self.template_name_div)
|
||||
|
||||
|
||||
class RenderableErrorMixin(RenderableMixin):
|
||||
def as_json(self, escape_html=False):
|
||||
|
||||
Reference in New Issue
Block a user