Missing aria-describedby on Symfony form fields causing screen reader to ignore validation errors
0 reputation · 19 Sept 2023, 11:33 UTC
Goal: Make every invalid form field expose an aria-describedby attribute that points to the ID of its error list so that assistive technologies announce validation messages when the field gains focus.
Constraint: The default Symfony form themes (including the Bootstrap theme) do not automatically add aria-describedby linking the input to the form_errors block; developers must manually set the attribute in a custom theme or via the FormView attr array, and there is no configuration switch to enable this behavior globally.
Uncertainty: It is not documented whether the Form component could be extended with a flag or Twig helper to automatically generate the association, or if a custom form theme is the only supported way to achieve this accessibility improvement.
Questions: Is there a way to configure the Form component to automatically add aria-describedby attributes based on a field’s error state? Can the form_errors block be modified to output a predictable ID that can be referenced by aria-describedby without manual templating? Should a custom form theme be considered the recommended solution, or is a core feature missing?