Opened 9 months ago

Last modified 9 months ago

#29056 assigned Bug

Required SelectDateWidget renders invalid HTML

Reported by: Vlastimil Zíma Owned by: Stanislav Filin
Component: Forms Version: master
Severity: Normal Keywords:
Cc: felixxm Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

SelectDateWidget in required field renders an invalid HTML. According to standard https://www.w3.org/TR/html5/sec-forms.html#placeholder-label-option every select with required attribute must have a placeholder option, i.e. first option must have an empty string as a value. That is not a case of SelectDateWidget.

Example

from django import forms
class FooForm(forms.Form):
    a_date = forms.DateField(widget=forms.SelectDateWidget)
form = FooForm()
str(form) # >>> ...<select name="a_date_month" required id="id_a_date_month"><option value="1">January</option>...

Change History (3)

comment:1 Changed 9 months ago by Stanislav Filin

Owner: changed from nobody to Stanislav Filin
Status: newassigned

I can fix this

comment:2 Changed 9 months ago by felixxm

Triage Stage: UnreviewedAccepted
Version: 2.0master

comment:3 Changed 9 months ago by felixxm

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