#36582: Accessibility improvement for required field labels for inline forms in 
the
admin.
-------------------------------------+-------------------------------------
     Reporter:  Antoliny             |                    Owner:  Antoliny
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |
    Component:  contrib.admin        |                  Version:  5.2
     Severity:  Normal               |               Resolution:
     Keywords:  accessibility        |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Antoliny):

 * stage:  Accepted => Unreviewed

Comment:

 I investigated why fields in admin inlines do not include the HTML
 required attribute.

 It turns out that inline forms in the admin are generated using Django’s
 `modelformset_factory`. Forms created through formsets do not render the
 required attribute on required fields.
 {{{
 # django/forms/formsets.py

 class BaseFormSet(RenderableFormMixin):
     ...
     def _construct_form(self, i, **kwargs):
         """Instantiate and return the i-th form instance in a formset."""
         defaults = {
             "auto_id": self.auto_id,
             "prefix": self.add_prefix(i),
             "error_class": self.error_class,
             # Don't render the HTML 'required' attribute as it may cause
             # incorrect validation for extra, optional, and deleted
             # forms in the formset.
             "use_required_attribute": False,
             "renderer": self.form_renderer,
         }
         ...
 }}}

 This behavior is also documented in the formset
 [https://docs.djangoproject.com/en/6.0/topics/forms/formsets/#formset-
 validation documentation].

 So this doesn’t seem to be an issue specific to the admin, but rather a
 broader accessibility concern with formsets.
 Since form fields in formsets don’t include the required attribute, screen
 reader users are unable to determine which fields are required in those
 forms.

 Should we consider adding another accessibility attribute to indicate
 required fields for assistive technologies?

 I’m reverting the ticket back to Unreviewed as it appears further triage
 is needed :)
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36582#comment:8>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019b0233c413-a349d137-1859-466e-97b5-4c975b60ac53-000000%40eu-central-1.amazonses.com.

Reply via email to