Fixed #18134 -- Inconsistent label_tag generation on form fields #141

Closed
wants to merge 2 commits into
from

2 participants

@gabejackson

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. CAUTION: This may be be "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.

Also some test cases regarding the label_tag output were inconsistent.
Some expected Label: and some expected the label_suffix
outside of the tag: Label:
The format has now been unified to keep the label_suffix inside the
tag: Label:. If the label_suffix is not needed,
the form can still be constructed with label_suffix=''.

gabejackson added some commits Jun 8, 2012
@gabejackson gabejackson Fixed #18134 -- Inconsistent label_tag generation on form fields
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. CAUTION: This may be be "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.

Also some test cases regarding the label_tag output were inconsistent.
Some expected <label>Label:</label> and some expected the label_suffix
outside of the <label> tag: <label>Label</label>:
The format has now been unified to keep the label_suffix inside the
<label> tag: <label>Label:</label>. If the label_suffix is not needed,
the form can still be constructed with label_suffix=''.
8fff02e
@gabejackson gabejackson Documentation for ticket #18134
Removed the extra ':' from the template examples in the forms
documentation. Noted that the label_tag template tag also outputs the
label_suffix.
8c5ef94
@timgraham
Django member

I've added additional docs for this change and updated it to merge cleanly: #1252

@timgraham timgraham closed this Jun 7, 2013
@nanuxbe nanuxbe pushed a commit to nanuxbe/django that referenced this pull request Jul 2, 2016
@olasitarska olasitarska Removed typekit logo from footer. Refs #141 6dc4cb1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment