Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#9486 closed (duplicate)

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

Reported by: ctao 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 mtredinnick)

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 ctao 6 years ago.

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by ctao

comment:1 Changed 6 years ago by hdevries

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 6 years ago by mtredinnick

  • Resolution set to duplicate
  • Status changed from new to closed

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 6 years ago by mtredinnick

  • 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 6 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

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