mirror of
https://github.com/django/django.git
synced 2025-07-23 13:15:32 +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:
parent
a643e4d200
commit
584bd14dcf
8 changed files with 77 additions and 34 deletions
|
@ -301,7 +301,7 @@ class UtilTests(SimpleTestCase):
|
|||
self.assertHTMLEqual(helpers.AdminField(form, 'text', is_first=False).label_tag(),
|
||||
'<label for="id_text" class="required inline"><i>text</i>:</label>')
|
||||
self.assertHTMLEqual(helpers.AdminField(form, 'cb', is_first=False).label_tag(),
|
||||
'<label for="id_cb" class="vCheckboxLabel required inline"><i>cb</i></label>')
|
||||
'<label for="id_cb" class="vCheckboxLabel required inline"><i>cb</i>:</label>')
|
||||
|
||||
# normal strings needs to be escaped
|
||||
class MyForm(forms.Form):
|
||||
|
@ -312,7 +312,7 @@ class UtilTests(SimpleTestCase):
|
|||
self.assertHTMLEqual(helpers.AdminField(form, 'text', is_first=False).label_tag(),
|
||||
'<label for="id_text" class="required inline">&text:</label>')
|
||||
self.assertHTMLEqual(helpers.AdminField(form, 'cb', is_first=False).label_tag(),
|
||||
'<label for="id_cb" class="vCheckboxLabel required inline">&cb</label>')
|
||||
'<label for="id_cb" class="vCheckboxLabel required inline">&cb:</label>')
|
||||
|
||||
def test_flatten_fieldsets(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue