Opened 19 years ago
Closed 19 years ago
#3809 closed (invalid)
Newforms Select widget has (invalid) "maxlength" attribute
| Reported by: | joe4444 | Owned by: | Adrian Holovaty |
|---|---|---|---|
| Component: | Forms | Version: | dev |
| Severity: | Keywords: | newforms select widget maxlength valid html | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
It seems that by default the Select widget produces a tag like this:
<select id="id_status" name="status" maxlength="30">
That causes an HTML validation error due to the maxlength="30" part.
Change History (4)
comment:1 by , 19 years ago
comment:3 by , 19 years ago
Looks like the real bug here is that the attrs dict you're passing gets modified by an internal method.
comment:4 by , 19 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
The real reason of your problem is #3810
Note:
See TracTickets
for help on using tickets.
I did a few more tests, and the widget does not produce this output by default. However, when applying attributes as follows, for some reason the maxlength="30" gets added.
req = {'class': 'required'} #... status = forms.ChoiceField(choices=MY_CHOICES, widget=forms.Select(attr=req))What does not make sense to me is that, although the following should be identical to the previous, it does not produce the same bug:
status = forms.ChoiceField(choices=MY_CHOICES, widget=forms.Select(attr={'class': 'required'}))Of course, the former is much more convenient, so it would be preferable if not for the strange HTML bug.
I do not think this is limited to select widgets, but I have not tested others yet.