From d8c9787bc01e61254be29070f161e87fb8a2744c Mon Sep 17 00:00:00 2001
From: skaught <skaught@gmail.com>
Date: Sat, 21 May 2016 12:00:44 -0400
Subject: [PATCH] 2560467 #9 Inline errors not shown for container elements

---
 core/includes/theme.inc                               |  6 ++++++
 core/modules/system/templates/container.html.twig     | 10 +++++++++-
 core/themes/classy/templates/form/container.html.twig | 10 +++++++++-
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 646e428..51eb60e 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1146,6 +1146,12 @@ function template_preprocess_container(&$variables) {
 
   $variables['children'] = $element['#children'];
   $variables['attributes'] = $element['#attributes'];
+
+  // Display any error messages.
+  $variables['errors'] = NULL;
+  if (!empty($element['#errors']) && empty($element['#error_no_message'])) {
+   $variables['errors'] = $element['#errors'];
+  }
 }
 
 /**
diff --git a/core/modules/system/templates/container.html.twig b/core/modules/system/templates/container.html.twig
index 6cb299b..02fe98c 100644
--- a/core/modules/system/templates/container.html.twig
+++ b/core/modules/system/templates/container.html.twig
@@ -12,6 +12,7 @@
  *
  * Available variables:
  * - attributes: HTML attributes for the containing element.
+ * - errors: (optional) Any errors for this container element, may not be set.
  * - children: The rendered child elements of the container.
  * - has_parent: A flag to indicate that the container has one or more parent
      containers.
@@ -27,4 +28,11 @@
     has_parent ? 'form-wrapper',
   ]
 %}
-<div{{ attributes.addClass(classes) }}>{{ children }}</div>
+<div{{ attributes.addClass(classes) }}>
+{% if errors %}
+  <div>
+    {{ errors }}
+  </div>
+{% endif %}
+{{ children }}
+</div>
diff --git a/core/themes/classy/templates/form/container.html.twig b/core/themes/classy/templates/form/container.html.twig
index 0da6c38..caafe73 100644
--- a/core/themes/classy/templates/form/container.html.twig
+++ b/core/themes/classy/templates/form/container.html.twig
@@ -12,6 +12,7 @@
  *
  * Available variables:
  * - attributes: HTML attributes for the containing element.
+ * - errors: (optional) Any errors for this container element, may not be set.
  * - children: The rendered child elements of the container.
  * - has_parent: A flag to indicate that the container has one or more parent
      containers.
@@ -25,4 +26,11 @@
     has_parent ? 'form-wrapper',
   ]
 %}
-<div{{ attributes.addClass(classes) }}>{{ children }}</div>
+<div{{ attributes.addClass(classes) }}>
+{% if errors %}
+  <div class="form-item--error-message">
+    <strong>{{ errors }}</strong>
+  </div>
+{% endif %}
+{{ children }}
+</div>
-- 
2.6.4

