diff --git a/django/forms/forms.py b/django/forms/forms.py
index 3299c2b..3dc27de 100644
a
|
b
|
class BaseForm(object):
|
170 | 170 | if self.label_suffix: |
171 | 171 | if label[-1] not in ':?.!': |
172 | 172 | label = format_html('{0}{1}', label, self.label_suffix) |
173 | | label = bf.label_tag(label) or '' |
| 173 | label = bf.label_tag(label, attrs={}) or '' |
174 | 174 | else: |
175 | 175 | label = '' |
176 | 176 | |
… |
… |
class BoundField(object):
|
507 | 507 | widget = self.field.widget |
508 | 508 | id_ = widget.attrs.get('id') or self.auto_id |
509 | 509 | if id_: |
| 510 | if (attrs is None and self.field.required and |
| 511 | hasattr(self.form, 'required_css_class')): |
| 512 | attrs = {'class': self.form.required_css_class} |
510 | 513 | attrs = attrs and flatatt(attrs) or '' |
511 | 514 | contents = format_html('<label for="{0}"{1}>{2}</label>', |
512 | 515 | widget.id_for_label(id_), attrs, contents |
diff --git a/tests/regressiontests/forms/tests/forms.py b/tests/regressiontests/forms/tests/forms.py
index a8a28ba..56f722f 100644
a
|
b
|
class FormsTestCase(TestCase):
|
1759 | 1759 | <tr><th><label for="id_email">Email:</label></th><td><input type="text" name="email" id="id_email" /></td></tr> |
1760 | 1760 | <tr class="required error"><th><label for="id_age">Age:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="age" id="id_age" /></td></tr>""") |
1761 | 1761 | |
| 1762 | self.assertHTMLEqual(p['age'].label_tag(), '<label for="id_age" class="required">Age</label>') |
| 1763 | |
1762 | 1764 | def test_label_split_datetime_not_displayed(self): |
1763 | 1765 | class EventForm(Form): |
1764 | 1766 | happened_at = SplitDateTimeField(widget=widgets.SplitHiddenDateTimeWidget) |