[Django] #32820: Django forms - fields’ errors should be programmatically associated with fields

50 views
Skip to first unread message

Django

unread,
Jun 5, 2021, 8:11:58 PM6/5/21
to django-...@googlegroups.com
#32820: Django forms - fields’ errors should be programmatically associated with
fields
-------------------------------------+-------------------------------------
Reporter: Thibaud | Owner: nobody
Colas |
Type: Bug | Status: new
Component: Forms | Version: 3.2
Severity: Normal | Keywords: accessibility, ui,
Triage Stage: | forms
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Related: [https://code.djangoproject.com/ticket/32819 #32819]. This could
be worth fixing at the same time, although I would expect this issue
shouldn’t require as breaking of a change to fix.

Django currently displays errors above fields in its forms rendering:


{{{
<ul class="errorlist">
<li>This field is required.</li>
</ul>
<p>
<label for="id_duration_required">Duration required:</label>
<input type="text" name="duration_required" required=""
id="id_duration_required">
<span class="helptext">Help</span>
</p>
}}}

One thing this is missing is a way to programmatically indicate the field
is in error – currently this can only be inferred visually because the
error messages are displayed above the field. This is fail of WCAG 2.1
level A [https://www.w3.org/WAI/WCAG21/Understanding/error-identification
3.3.1: Error Identification]. The most common way to do this
programmatically is to use `aria-invalid="true"` on the field, as
demonstrated in the non-normative
[https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA21 technique ARIA21]:

{{{
<input type="text" name="duration_required" required=""
id="id_duration_required" aria-invalid="true">
}}}

Here is the result in VoiceOver on Safari – announcing "invalid data"
after the field label and required state:

Screenshot of the VoiceOver text-to-speech output, announcing "Email
required: required invalid data edit text"

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

Django

unread,
Jun 5, 2021, 8:12:18 PM6/5/21
to django-...@googlegroups.com
#32820: Django forms - fields’ errors should be programmatically associated with
fields
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: nobody

Type: Bug | Status: new
Component: Forms | Version: 3.2
Severity: Normal | Resolution:

Keywords: accessibility, ui, | Triage Stage:
forms | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Thibaud Colas):

* Attachment "email-required-aria-invalid.png" added.

Django

unread,
Jun 5, 2021, 8:13:00 PM6/5/21
to django-...@googlegroups.com
#32820: Django forms - fields’ errors should be programmatically associated with
fields
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: nobody

Type: Bug | Status: new
Component: Forms | Version: 3.2
Severity: Normal | Resolution:

Keywords: accessibility, ui, | Triage Stage:
forms | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Thibaud Colas:

Old description:

New description:

[[Image(https://code.djangoproject.com/raw-attachment/ticket/32820/email-
required-aria-invalid.png)]]

--

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

Django

unread,
Jun 6, 2021, 11:55:28 PM6/6/21
to django-...@googlegroups.com
#32820: Django forms - fields’ errors should be programmatically associated with
fields
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: nobody

Type: Bug | Status: new
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |

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

* stage: Unreviewed => Accepted


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

Django

unread,
Jun 6, 2021, 11:56:00 PM6/6/21
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.

-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |

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

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

Django

unread,
Jun 16, 2021, 1:44:19 PM6/16/21
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |

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

Comment (by Chandu-4444):

Hey, can I work on this? I'm a beginner here, any kind of help would be
greatly appreciated.

Thanks,
Kiran

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

Django

unread,
Jul 16, 2021, 11:39:25 AM7/16/21
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |

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

Comment (by Tom Carrick):

Kiran, assign yourself the ticket if you want to take it. If you need
help, I would first read
https://docs.djangoproject.com/en/3.2/internals/contributing/ and try to
get the tests passing at least.

You would probably need to find where the HTML for these forms are
generated. I think
https://github.com/django/django/tree/main/django/forms/templates/django/forms/widgets
might be a good place to start. Then find out the best way to tell if the
field is invalid and the best place to add the attribute.

If you get stuck, you could try posting on the forum or the django-
developers mailing list.

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

Django

unread,
Aug 3, 2021, 2:21:55 AM8/3/21
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: kackey0-1
Type: Bug | Status: assigned
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |

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

* owner: nobody => kackey0-1
* status: new => assigned


Comment:

Let me work on this.

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

Django

unread,
Aug 3, 2021, 9:07:28 AM8/3/21
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: (none)

Type: Bug | Status: new
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |

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

* owner: kackey0-1 => (none)
* status: assigned => new


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

Django

unread,
Sep 9, 2021, 1:54:18 PM9/9/21
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: Kapil
| Bansal
Type: Bug | Status: assigned
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |

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

* owner: (none) => Kapil Bansal


* status: new => assigned


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

Django

unread,
Sep 9, 2021, 2:02:49 PM9/9/21
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: Kapil
| Bansal
Type: Bug | Status: assigned
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |

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

Comment (by Kapil Bansal):

If I am not wrong, we need to remove the errorlist and use aria_techniques
instead?

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

Django

unread,
Oct 30, 2021, 7:56:21 AM10/30/21
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: Demetris
| Stavrou
Type: Bug | Status: assigned
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |

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

* owner: Kapil Bansal => Demetris Stavrou


Comment:

I will give this a try since there is inactivity.

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

Django

unread,
Jan 10, 2022, 5:43:45 AM1/10/22
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: Demetris
| Stavrou
Type: Bug | Status: assigned
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |

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

Comment (by Thibaud Colas):

Note based on recent research for PR #15036
(https://github.com/django/django/pull/15036#issuecomment-1008738687):

- I still think this is a _Bug_ (WCAG 2.1 conformance fail) as Django
stands currently, however if/when ticket #32819 is tackled, we should mark
this ticket as a _New feature_, as contrary to what I thought `aria-
invalid="true"` isn’t required for conformance when `aria-describedby`
already points to an error message. If the error message can’t be
identified as such, then the bug to fix would be to make the error
messages unambiguous, which is a different issue.
- Even though I would expect fixing this to be a straightforward
improvement for almost all Django implementers, it’ll change how forms are
announced to screen reader users, so it would be valid to consider this as
a breaking change.

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

Django

unread,
Dec 24, 2022, 8:29:16 AM12/24/22
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: Demetris
| Stavrou
Type: Bug | Status: assigned
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32820#comment:12>

Django

unread,
Jun 2, 2023, 10:32:37 AM6/2/23
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: Gregor
| Jerše
Type: Bug | Status: assigned
Component: Forms | Version: dev

Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gregor Jerše):

* owner: Demetris Stavrou => Gregor Jerše
* version: 3.2 => dev


--
Ticket URL: <https://code.djangoproject.com/ticket/32820#comment:13>

Django

unread,
Jun 2, 2023, 3:02:38 PM6/2/23
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: Gregor
| Jerše
Type: Bug | Status: assigned
Component: Forms | Version: dev
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Natalia Bidart):

There is a new [https://github.com/django/django/pull/16933 PR here]

--
Ticket URL: <https://code.djangoproject.com/ticket/32820#comment:14>

Django

unread,
Jul 28, 2023, 10:25:06 AM7/28/23
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: David
| Smith

Type: Bug | Status: assigned
Component: Forms | Version: dev
Severity: Normal | Resolution:
Keywords: accessibility, ui, | Triage Stage: Accepted
forms |
Has patch: 1 | Needs documentation: 0

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

* owner: Gregor Jerše => David Smith
* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/32820#comment:15>

Django

unread,
Aug 1, 2023, 1:59:28 AM8/1/23
to django-...@googlegroups.com
#32820: Fields’ errors should be programmatically associated with fields.
-------------------------------------+-------------------------------------
Reporter: Thibaud Colas | Owner: David
| Smith
Type: Bug | Status: closed
Component: Forms | Version: dev
Severity: Normal | Resolution: fixed

Keywords: accessibility, ui, | Triage Stage: Accepted
forms |
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:"10725a31879c55ba8d92aaa3275093d136957bef" 10725a3]:
{{{
#!CommitTicketReference repository=""
revision="10725a31879c55ba8d92aaa3275093d136957bef"
Fixed #32820 -- Added aria-invalid="true" to fields with errors.

Co-authored-by: Demetris Stavrou <deme...@gmail.com>
Co-authored-by: David Smith <smi...@gmail.com>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32820#comment:16>

Reply all
Reply to author
Forward
0 new messages