Ticket #34705: boundfield-as_widget-aria_describedby.patch

File boundfield-as_widget-aria_describedby.patch, 831 bytes (added by Sage Abdullah, 16 months ago)

Patch to fix the issue

  • django/forms/boundfield.py

    diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py
    index deba739329..b9f29e3da5 100644
    a b class BoundField(RenderableFieldMixin):  
    290290        # If a custom aria-describedby attribute is given and help_text is
    291291        # used, the custom aria-described by is preserved so user can set the
    292292        # desired order.
    293         if custom_aria_described_by_id := widget.attrs.get("aria-describedby"):
     293        if custom_aria_described_by_id := attrs.get(
     294            "aria-describedby"
     295        ) or widget.attrs.get("aria-describedby"):
    294296            attrs["aria-describedby"] = custom_aria_described_by_id
    295297        elif self.field.help_text and self.id_for_label:
    296298            attrs["aria-describedby"] = f"{self.id_for_label}_helptext"
Back to Top