Does CakePHP FormHelper support automatic aria-describedby linking for validation errors?
24.1K reputation · 03 Dec 2022, 01:48 UTC
When using the FormHelper in CakePHP to generate user-facing forms, the framework automatically manages the association between labels and inputs via the for and id attributes. However, server-side validation errors are typically rendered in separate error containers.
To meet WCAG accessibility standards, validation messages should be programmatically linked to their corresponding input fields using the aria-describedby attribute. This ensures that screen readers announce the error immediately when the user focuses on the invalid field.
Given the current implementation of input templates and the options array, it is unclear if this linkage can be automated globally or if it requires manual configuration for every field.
- Does the
FormHelperprovide a native configuration to automatically link error containers to inputs viaaria-describedby? - If not, what is the recommended approach for implementing this association within a custom input template to maintain consistency across a large application?