diff -u b/core/lib/Drupal/Core/Render/Element/RenderElement.php b/core/lib/Drupal/Core/Render/Element/RenderElement.php --- b/core/lib/Drupal/Core/Render/Element/RenderElement.php +++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php @@ -197,13 +197,17 @@ elseif (!empty($element['#group_details'])) { // Intentionally empty to clarify the flow; we simply return $element. } - // Otherwise, this element belongs to a group and the group exists, so we do - // not render it. + // Otherwise, this element belongs to a group and the group exists, so we + // do not render it. elseif (Element::children($element['#groups'][$group])) { $element['#printed'] = TRUE; } } - $element['#attributes']['class'][] = 'error'; + + // Set attributes to indicate that there is a child with an error. + if (!empty($element['#children_errors'])) { + $element['#attributes']['class'][] = 'error'; + } return $element; }