If an error is set on an element with #tree
is TRUE
. A duplicate child error is recorded in the #children_errors
property of all parent elements for each child element.
In other words, if a single error is set on, for example, a compound field. All parent elements / wrappers of this compound field think there are multiple children errors. The more fields a compound field exists of the more duplicate children errors are recorded.
This has been identified in #2848507-74: Indicate that grouping elements have child element errors for ux and a11y and causes a bug for screen readers.
The nature of the problem is two-fold:
1) Errors bubble up when #tree
is TRUE
- In: getError()
(Drupal\Core\Form\FormState).
2) When collecting children errors bubbled up errors are not ignored. - In: setElementErrorsFromFormState()
(Drupal\Core\Form\FormErrorHandler).
Proposed solution:
Don't register bubbled up errors as child error, only use the original.
Comments
Comment #2
dmsmidtComment #3
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedUpdating issue title, hopefully make more sense when I link to to it from the IFE roadmap follow-ups section.
Comment #4
dmsmidt@andrew, well what you describe is just one example. Not only is the count off, also the error messages themselves are internally set multiple times. And also non-compound form structures can exhibit this problem if they do complex stuff with nesting and setting errors on parents.
Anyhow, that's is shown in the IS.