[Django] #29056: Required SelectDateWidget renders invalid HTML

18 views
Skip to first unread message

Django

unread,
Jan 25, 2018, 3:44:30 AM1/25/18
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
------------------------------------------+------------------------
Reporter: Vlastimil Zíma | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
`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 ===
{{{
#!python
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>...
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29056>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 25, 2018, 4:11:16 AM1/25/18
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
-------------------------------------+-------------------------------------
Reporter: Vlastimil Zíma | Owner: Stanislav
| Filin
Type: Bug | Status: assigned
Component: Forms | Version: 2.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Stanislav Filin):

* owner: nobody => Stanislav Filin
* status: new => assigned


Comment:

I can fix this

--
Ticket URL: <https://code.djangoproject.com/ticket/29056#comment:1>

Django

unread,
Jan 25, 2018, 4:13:22 AM1/25/18
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
-------------------------------------+-------------------------------------
Reporter: Vlastimil Zíma | Owner: Stanislav
| Filin
Type: Bug | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* version: 2.0 => master
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/29056#comment:2>

Django

unread,
Jan 25, 2018, 4:13:34 AM1/25/18
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
-------------------------------------+-------------------------------------
Reporter: Vlastimil Zíma | Owner: Stanislav
| Filin
Type: Bug | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* cc: felixxm (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29056#comment:3>

Django

unread,
May 4, 2019, 7:44:01 PM5/4/19
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
--------------------------------+------------------------------------------
Reporter: Vlastimil Zíma | Owner: Hasan Ramezani

Type: Bug | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------------
Changes (by Hasan Ramezani):

* owner: Stanislav Filin => Hasan Ramezani
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29056#comment:4>

Django

unread,
May 8, 2019, 7:52:26 AM5/8/19
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
--------------------------------+------------------------------------------
Reporter: Vlastimil Zíma | Owner: Hasan Ramezani
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"f038214d917c982613f5a15db8dfe325b1f7479b" f038214d]:
{{{
#!CommitTicketReference repository=""
revision="f038214d917c982613f5a15db8dfe325b1f7479b"
Fixed #29056 -- Fixed HTML5 validation of required SelectDateWidget.

placeholder is required for "select" with "required" attribute.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29056#comment:5>

Django

unread,
Nov 21, 2019, 3:09:39 AM11/21/19
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
-------------------------------------+-------------------------------------

Reporter: Vlastimil Zíma | Owner: Hasan
| Ramezani
Type: Bug | Status: new
Component: Forms | Version: 3.0
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Baptiste Mispelon):

* status: closed => new
* version: master => 3.0
* resolution: fixed =>
* severity: Normal => Release blocker


Comment:

According to #31012 (which I just closed as a duplicated), the fix for
this ticket is not correct (and should probably be reverted).

There's more detail in the duplicate ticket but if I understand correctly,
the term "placeholder" in the spec does not refer to the "placeholder"
attribute that other tags can have.
A "placeholder" option is an `<option>` tag with an empty value that has
to be the first direct element of the `<select>`.

The duplicate ticket has a pull request at
https://github.com/django/django/pull/12116.

--
Ticket URL: <https://code.djangoproject.com/ticket/29056#comment:6>

Django

unread,
Nov 21, 2019, 3:14:43 AM11/21/19
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
--------------------------------+------------------------------------------

Reporter: Vlastimil Zíma | Owner: Hasan Ramezani
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* version: 3.0 => master
* resolution: => fixed
* severity: Release blocker => Normal


Comment:

HI Baptiste. The new ticket is highlighting a regression introduced here.
It's not a duplicate. But it will be a Release Blocker, yes. (I'm just
Reviewing it now...)

--
Ticket URL: <https://code.djangoproject.com/ticket/29056#comment:7>

Django

unread,
Nov 21, 2019, 3:43:20 AM11/21/19
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
--------------------------------+------------------------------------------
Reporter: Vlastimil Zíma | Owner: Hasan Ramezani
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------------

Comment (by Carlton Gibson):

Worth noting for future reference from #31012:

> It's also important to note that the HTML generated for the
SelectDateWidget in previous versions of Django was valid per the HTML
standard. They did not contain a placeholder label option, but because
they were not a <select multiple> they always contained an option with a
selectedness set to true (usually the first option). This meant that the
required attribute generated for them was useless, since it would never
not have a value or be empty, but it did mean it was still valid HTML.

--
Ticket URL: <https://code.djangoproject.com/ticket/29056#comment:8>

Django

unread,
Nov 21, 2019, 2:54:14 PM11/21/19
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
--------------------------------+------------------------------------------
Reporter: Vlastimil Zíma | Owner: Hasan Ramezani
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"ee4a19053a32d41cdd79e087b1968980804ce658" ee4a1905]:
{{{
#!CommitTicketReference repository=""
revision="ee4a19053a32d41cdd79e087b1968980804ce658"
Fixed #31012 -- Reverted "Fixed #29056 -- Fixed HTML5 validation of
required SelectDateWidget."

This reverts commit f038214d917c982613f5a15db8dfe325b1f7479b.

The initial issue was incorrect. Django 2.2, and before, did not
generate invalid HTML as reported. With f03821 in place invalid HTML
was generated.

Thanks to Kevin Brown for follow-up report and investigation.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29056#comment:9>

Django

unread,
Nov 21, 2019, 3:07:22 PM11/21/19
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
--------------------------------+------------------------------------------
Reporter: Vlastimil Zíma | Owner: Hasan Ramezani
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"947f8e3485b1406d18ea062fd275c083d7ffbed5" 947f8e3]:
{{{
#!CommitTicketReference repository=""
revision="947f8e3485b1406d18ea062fd275c083d7ffbed5"
[3.0.x] Fixed #31012 -- Reverted "Fixed #29056 -- Fixed HTML5 validation
of required SelectDateWidget."

This reverts commit f038214d917c982613f5a15db8dfe325b1f7479b.

The initial issue was incorrect. Django 2.2, and before, did not
generate invalid HTML as reported. With f03821 in place invalid HTML
was generated.

Thanks to Kevin Brown for follow-up report and investigation.

Backport of ee4a19053a32d41cdd79e087b1968980804ce658 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29056#comment:10>

Django

unread,
Nov 25, 2019, 3:02:41 PM11/25/19
to django-...@googlegroups.com
#29056: Required SelectDateWidget renders invalid HTML
--------------------------------+------------------------------------------
Reporter: Vlastimil Zíma | Owner: Hasan Ramezani
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------------

Comment (by Vlastimil Zíma):

When reported, the `SelectDateWidget` actually rendered invalid HTML, but
it was fixed as a side-effect of #29036. Looks like I've created this
ticket during the discussion and forgot to close it afterwards.

--
Ticket URL: <https://code.djangoproject.com/ticket/29056#comment:11>

Reply all
Reply to author
Forward
0 new messages