Check username field label for None
|Reported by:||zhenghao12@…||Owned by:||nobody|
|Cc:||stefan.berder@…||Triage Stage:||Ready for checkin|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||no|
Sometimes when designing "log-in" forms, there is a necessity to hide the labels and use input element placeholders to identify the fields. When I entered the following in my form:
username = CharField(label='')
the generated HTML still contained the Username <label> element.
It turns out that in line 173 of django.contrib.auth.forms, the boolean test is too broad/generic. It does not take into consideration when the label is deliberately set to an empty string.
The fix to this would affect django/contrib/auth/forms.py file.
Change History (3)
comment:1 Changed 3 years ago by charettes
- Needs documentation unset
- Needs tests set
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
- Version changed from 1.5 to master