[Django] #18134: please add Filed.label_tag_with_suffix method

45 views
Skip to first unread message

Django

unread,
Apr 14, 2012, 6:14:13 PM4/14/12
to django-...@googlegroups.com
#18134: please add Filed.label_tag_with_suffix method
-----------------------------------------+--------------------
Reporter: Evil Clay <clay.evil@…> | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------------+--------------------
there were some tickets about label_tag not respecting the label_suffix
which is not always right. would it be possible to add a
label_tag_with_suffix method so all can be happy?
Thank you.

--
Ticket URL: <https://code.djangoproject.com/ticket/18134>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 15, 2012, 7:22:09 PM4/15/12
to django-...@googlegroups.com
#18134: please add Filed.label_tag_with_suffix method
-------------------------------------+-------------------------------------
Reporter: Evil Clay | Owner: nobody
<clay.evil@…> | Status: closed
Type: Uncategorized | Version: 1.4
Component: Uncategorized | Resolution: invalid
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by russellm):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

As a guide for the future -- when opening a ticket, it's helpful to
provide details about exactly what it is you're proposing to fix/change.
"Some tickets" referring to a random method name isn't very helpful;
suggesting a fix without describing the actual problem also isn't helpful.

In this case, it isn't clear if you're referring to "label_tag" on the
BoundField of a form, or "label_tag" on an AdminField (neither of which
are documented API entry points). Without a specific reference to tickets,
it's impossible to know problem what adding "label_tag_with_suffix" would
fix. However, given the current operation of "label_tag", I can't see how
adding a second method to do the same thing would improve anything.

Closing invalid. If you want to provide more details -- like, for example,
the problem you're trying to address, and and example of how
label_tag_with_suffix would address that problem -- feel free to reopen.

--
Ticket URL: <https://code.djangoproject.com/ticket/18134#comment:1>

Django

unread,
Apr 16, 2012, 2:57:31 AM4/16/12
to django-...@googlegroups.com
#18134: please add Filed.label_tag_with_suffix method
-------------------------------------+-------------------------------------
Reporter: Evil Clay | Owner: nobody
<clay.evil@…> | Status: reopened
Type: Uncategorized | Version: 1.4
Component: Uncategorized | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Evil Clay <clay.evil@…>):

* status: closed => reopened
* resolution: invalid =>


Comment:

I'm sorry, my knowledge of djnago is limited unlike yours, i didn't know
that this method exists on more places.

I'm referring to https://docs.djangoproject.com/en/1.4/topics/forms/
(Customizing the form template)
{{ field.label_tag }}
The field's label wrapped in the appropriate HTML <label> tag, e.g. <label
for="id_email">Email address</label>

and also to Ticket #6877 where it is explained why the field.label_tag
doesn't respect the form's label_suffix which i understand.

The problem is that if i use in my project in as many pages as i can the
{{ form.as_p }} to respect the DRY, but in some cases you have to add some
HTML code in the form, so you have to manually render the form usually
like this:
<p>
{{ form.name.errors }}[[BR]]
{{ form.name.label_tag }}{{ form.name }}<span
class="helptext">{{ form.name.help_text }}</span>
</p>
which would render the form without the label_suffix (i.e. without the ":"
in the label).

so you would have to do it like this:
<p>
{{ form.name.errors }}[[BR]]
<label for="id_name ">{{ form.name.label }}:</label>{{
form.name }}<span class="helptext">{{ form.name.help_text }}</span>
</p>
which forces you to dirty write the "id_name" where the "id_" is as far as
i know configurable in forms so this would be an incorrect way of doing
it.

my proposal is to add {{ form.name.label_tag_with_suffix }} method which
would solve the problem.

--
Ticket URL: <https://code.djangoproject.com/ticket/18134#comment:2>

Django

unread,
Jun 8, 2012, 10:40:43 AM6/8/12
to django-...@googlegroups.com
#18134: please add Filed.label_tag_with_suffix method
-------------------------------------+-------------------------------------
Reporter: Evil Clay | Owner:
<clay.evil@…> | gabejackson
Type: | Status: new
Cleanup/optimization | Version: 1.4
Component: Uncategorized | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: forms | Needs documentation: 1
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by gabejackson):

* status: reopened => new
* owner: nobody => gabejackson
* keywords: => forms
* needs_docs: 0 => 1
* has_patch: 0 => 1
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

This has been fixed and discussed in
https://github.com/django/django/pull/141

A copy of the commit:
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=''.

--
Ticket URL: <https://code.djangoproject.com/ticket/18134#comment:3>

Django

unread,
Jun 8, 2012, 10:57:28 AM6/8/12
to django-...@googlegroups.com
#18134: please add Filed.label_tag_with_suffix method
-------------------------------------+-------------------------------------
Reporter: Evil Clay | Owner:
<clay.evil@…> | gabejackson
Type: | Status: assigned
Cleanup/optimization | Version: 1.4
Component: Uncategorized | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: forms | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by gabejackson):

* status: new => assigned
* needs_docs: 1 => 0


Comment:

Documentation has been changed.

https://github.com/django/django/pull/143

--
Ticket URL: <https://code.djangoproject.com/ticket/18134#comment:4>

Django

unread,
Jun 8, 2012, 1:59:44 PM6/8/12
to django-...@googlegroups.com
#18134: please add Filed.label_tag_with_suffix method
-------------------------------------+-------------------------------------
Reporter: Evil Clay | Owner:
<clay.evil@…> | gabejackson
Type: | Status: assigned
Cleanup/optimization | Version: 1.4
Component: Uncategorized | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: forms | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Evil Clay <clay.evil@…>):

Thank you, you're Godlike.

--
Ticket URL: <https://code.djangoproject.com/ticket/18134#comment:5>

Django

unread,
Mar 15, 2013, 3:59:51 AM3/15/13
to django-...@googlegroups.com
#18134: please add Filed.label_tag_with_suffix method
-------------------------------------+-------------------------------------
Reporter: Evil Clay | Owner:
<clay.evil@…> | gabejackson
Type: | Status: assigned
Cleanup/optimization | Version: 1.4
Component: Forms | Resolution:

Severity: Normal | Triage Stage: Accepted
Keywords: forms | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* component: Uncategorized => Forms


--
Ticket URL: <https://code.djangoproject.com/ticket/18134#comment:6>

Django

unread,
Jun 7, 2013, 1:07:17 PM6/7/13
to django-...@googlegroups.com
#18134: BoundField.label_tag should include form.label_suffix

-------------------------------------+-------------------------------------
Reporter: Evil Clay | Owner:
<clay.evil@…> | gabejackson
Type: | Status: assigned
Cleanup/optimization | Version: 1.4
Component: Forms | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: forms | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* cc: timograham@… (added)


Comment:

This change makes sense to me. I've added a note to the "backwards
incompatible changes" section of the release notes and updated the request
to merge cleanly.

https://github.com/django/django/pull/1252

--
Ticket URL: <https://code.djangoproject.com/ticket/18134#comment:7>

Django

unread,
Jun 10, 2013, 2:23:35 PM6/10/13
to django-...@googlegroups.com
#18134: BoundField.label_tag should include form.label_suffix
-------------------------------------+-------------------------------------
Reporter: Evil Clay | Owner:
<clay.evil@…> | gabejackson
Type: | Status: closed
Cleanup/optimization | Version: 1.4
Component: Forms | Resolution: fixed

Severity: Normal | Triage Stage: Accepted
Keywords: forms | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"584bd14dcfdee9585fec7794d53ce120ea73d0bc"]:
{{{
#!CommitTicketReference repository=""
revision="584bd14dcfdee9585fec7794d53ce120ea73d0bc"
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.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18134#comment:8>

Django

unread,
Jul 2, 2013, 2:15:44 PM7/2/13
to django-...@googlegroups.com
#18134: BoundField.label_tag should include form.label_suffix
-------------------------------------+-------------------------------------
Reporter: Evil Clay | Owner:
<clay.evil@…> | gabejackson
Type: | Status: closed
Cleanup/optimization | Version: 1.4
Component: Forms | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: forms | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"3632d289dedc2e83cde1976e5a4cd00b08c799ee"]:
{{{
#!CommitTicketReference repository=""
revision="3632d289dedc2e83cde1976e5a4cd00b08c799ee"
A couple more semicolon -> colon fixes; refs #18134.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18134#comment:9>

Django

unread,
Jul 2, 2013, 2:16:49 PM7/2/13
to django-...@googlegroups.com
#18134: BoundField.label_tag should include form.label_suffix
-------------------------------------+-------------------------------------
Reporter: Evil Clay | Owner:
<clay.evil@…> | gabejackson
Type: | Status: closed
Cleanup/optimization | Version: 1.4
Component: Forms | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: forms | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"5ecdf0eb9ccd47c102deb873a242ed40d1cf45cd"]:
{{{
#!CommitTicketReference repository=""
revision="5ecdf0eb9ccd47c102deb873a242ed40d1cf45cd"
[1.6.x] A couple more semicolon -> colon fixes; refs #18134.

Backport of 3632d289de from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18134#comment:10>

Django

unread,
May 13, 2014, 9:13:17 AM5/13/14
to django-...@googlegroups.com
#18134: BoundField.label_tag should include form.label_suffix
-------------------------------------+-------------------------------------
Reporter: Evil Clay | Owner:
<clay.evil@…> | gabejackson
Type: | Status: closed
Cleanup/optimization | Version: 1.4
Component: Forms | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: forms | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"5eb81ce44532596ecc1c781d93f3421a467a6206"]:
{{{
#!CommitTicketReference repository=""
revision="5eb81ce44532596ecc1c781d93f3421a467a6206"
Fixed #22533 -- Added label_suffix parameter to form fields.

Fields can now receive the `label_suffix` attribute, which will override
a form's `label_suffix`.

This enhances the possibility to customize form's `label_suffix`, allowing
to use such customizations while using shortcuts such as
`{{ form.as_p }}`.

Note that the field's own customization can be overridden at runtime by
using the `label_prefix` parameter to `BoundField.label_tag()`.

Refs #18134.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18134#comment:11>

Reply all
Reply to author
Forward
0 new messages