Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#9486 closed (duplicate)

The goal is to make sure the required field's lable be bold

Reported by: tangc Owned by: nobody
Component: Uncategorized Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by Malcolm Tredinnick)

Here is the svn diff

Index: django/forms/forms.py
===================================================================
--- django/forms/forms.py       (revision 9084)
+++ django/forms/forms.py       (working copy)
@@ -155,7 +155,13 @@
                     if self.label_suffix:
                         if label[-1] not in ':?.!':
                             label += self.label_suffix
-                    label = bf.label_tag(label) or ''
+
+                    attrs = None
+                    if bf.field.required:
+                        attrs = {'class': 'required'}
+
+                    label = bf.label_tag(label, attrs) or ''
+
                 else:
                     label = ''
                 if field.help_text:

Attachments (1)

9486.diff (729 bytes) - added by tangc 8 years ago.

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by tangc

Attachment: 9486.diff added

comment:1 Changed 8 years ago by Henk de Vries

Hmm, I think you should check for form errors in the template and then style your label accordingly. IMHO this shouldn't be put into trunk simply because it forces a certain style onto the Django user.
What if he/she want his/her label to be a Pony when a field is required?

About your patch:
It hasn't got tests, check the contributing guidelines in the docs.

comment:2 Changed 8 years ago by Malcolm Tredinnick

Resolution: duplicate
Status: newclosed

Basically a duplicate of #3512 and #3515 (this is just one specialised case of those). One day we'll make a decision about how to handle those cases.

comment:3 Changed 8 years ago by Malcolm Tredinnick

Description: modified (diff)

(Edited description because, due to a Trac bug, it was messing up the formatting of the rest of the page.)

comment:4 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top