mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #18134 -- BoundField.label_tag now includes the form's label_suffix
There was an inconsistency between how the label_tag for forms were generated depending on which method was used: as_p, as_ul and as_table contained code to append the label_suffix where as label_tag called on a form field directly did NOT append the label_suffix. The code for appending the label_suffix has been moved in to the label_tag code of the field and the HTML generation code for as_p, as_ul and as_table now calls this code as well. This is a backwards incompatible change because users who have added the label_suffix manually in their templates may now get double label_suffix characters in their forms.
This commit is contained in:
@@ -302,7 +302,7 @@ loop::
|
||||
{% for field in form %}
|
||||
<div class="fieldWrapper">
|
||||
{{ field.errors }}
|
||||
{{ field.label_tag }}: {{ field }}
|
||||
{{ field.label_tag }} {{ field }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<p><input type="submit" value="Send message" /></p>
|
||||
@@ -316,8 +316,14 @@ attributes, which can be useful in your templates:
|
||||
The label of the field, e.g. ``Email address``.
|
||||
|
||||
``{{ field.label_tag }}``
|
||||
The field's label wrapped in the appropriate HTML ``<label>`` tag,
|
||||
e.g. ``<label for="id_email">Email address</label>``
|
||||
The field's label wrapped in the appropriate HTML ``<label>`` tag.
|
||||
|
||||
.. versionchanged:: 1.6
|
||||
|
||||
This includes the form's :attr:`~django.forms.Form.label_suffix`. For
|
||||
example, the default ``label_suffix`` is a semicolon::
|
||||
|
||||
<label for="id_email">Email address:</label>
|
||||
|
||||
``{{ field.value }}``
|
||||
The value of the field. e.g ``someone@example.com``
|
||||
@@ -375,7 +381,7 @@ these two methods::
|
||||
{% for field in form.visible_fields %}
|
||||
<div class="fieldWrapper">
|
||||
{{ field.errors }}
|
||||
{{ field.label_tag }}: {{ field }}
|
||||
{{ field.label_tag }} {{ field }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<p><input type="submit" value="Send message" /></p>
|
||||
@@ -403,7 +409,7 @@ using the :ttag:`include` tag to reuse it in other templates::
|
||||
{% for field in form %}
|
||||
<div class="fieldWrapper">
|
||||
{{ field.errors }}
|
||||
{{ field.label_tag }}: {{ field }}
|
||||
{{ field.label_tag }} {{ field }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
@@ -907,7 +907,7 @@ Third, you can manually render each field::
|
||||
{{ formset.management_form }}
|
||||
{% for form in formset %}
|
||||
{% for field in form %}
|
||||
{{ field.label_tag }}: {{ field }}
|
||||
{{ field.label_tag }} {{ field }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user