diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 95c8911..781529d 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1150,7 +1150,7 @@ function template_preprocess_container(&$variables) { // Display any error messages. $variables['errors'] = NULL; if (!empty($element['#errors']) && empty($element['#error_no_message'])) { - $variables['errors'] = $element['#errors']; + $variables['errors'] = $element['#errors']; } } diff --git a/core/modules/system/src/Tests/Form/ElementTest.php b/core/modules/system/src/Tests/Form/ElementTest.php index 0d8c125..d14658a 100644 --- a/core/modules/system/src/Tests/Form/ElementTest.php +++ b/core/modules/system/src/Tests/Form/ElementTest.php @@ -185,7 +185,7 @@ public function testFormDetailsErrors() { /** * Tests form container element error messages. */ - public function testFormElementErrors() { + public function testFormContainerErrors() { $this->drupalPostForm('form_test/container-form', [], 'Submit'); $this->assertText('I am an error on the container element.'); } diff --git a/core/modules/system/tests/modules/form_test/form_test.routing.yml b/core/modules/system/tests/modules/form_test/form_test.routing.yml index d983671..9a4bc06 100644 --- a/core/modules/system/tests/modules/form_test/form_test.routing.yml +++ b/core/modules/system/tests/modules/form_test/form_test.routing.yml @@ -421,7 +421,7 @@ form_test.container_form: path: '/form_test/container-form' defaults: _form: '\Drupal\form_test\Form\FormTestContainerForm' - _title: 'Form contaner form test' + _title: 'Form container form test' requirements: _access: 'TRUE' diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestContainerForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestContainerForm.php index e013484..db0481f 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestContainerForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestContainerForm.php @@ -29,7 +29,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ]; $form['meta']['child'] = [ '#type' => 'textfield', - '#title' => 'a textfield in a container', + '#title' => 'A textfield in a container', ]; $form['submit'] = ['#type' => 'submit', '#value' => 'Submit']; return $form; diff --git a/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php b/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php index 05f0b00..1cb4400 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/StyleMappingTest.php @@ -64,15 +64,11 @@ protected function mappedOutputHelper($view) { $name = strtok((string) $field_attributes['class'][0], '-'); $field_id = strtok('-'); - /** - * The expected result is the mapping name and the field value, - * separated by ':'. - * - * [#2560467] Fix for unknown line returns being added in. - */ - $expected_result = preg_replace(array('/\r/', '/\n/'), '', $name . ':' . $data_set[$count][$field_id]); - $actual_result = preg_replace(array('/\r/', '/\n/'), '', (string) $field); - $this->assertEqual($actual_result, $expected_result,format_string('The fields were mapped successfully: %expected_result => %actual_result', array('%expected_result' => $expected_result, '%actual_result' => $actual_result))); + // The expected result is the mapping name and the field value, + // separated by ':'. + $expected_result = $name . ':' . $data_set[$count][$field_id]; + $actual_result = (string) $field; + $this->assertIdentical($expected_result, $actual_result, format_string('The fields were mapped successfully: %name => %field_id', array('%name' => $name, '%field_id' => $field_id))); } $count++; diff --git a/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php b/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php index 97c56c0..3e11695 100644 --- a/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php +++ b/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php @@ -56,7 +56,7 @@ function testContainer() { $this->assertElements(array( '#type' => 'container', '#markup' => 'foo', - ), "
\nfoo\n
\n", "#type 'container' with no HTML attributes"); + ), "
foo
\n", "#type 'container' with no HTML attributes"); // Container with a class. $this->assertElements(array( @@ -65,7 +65,7 @@ function testContainer() { '#attributes' => array( 'class' => array('bar'), ), - ), '
' . "\n" . 'foo' . "\n" . '
' . "\n", "#type 'container' with a class HTML attribute"); + ), '
foo
' . "\n", "#type 'container' with a class HTML attribute"); // Container with children. $this->assertElements(array( @@ -73,7 +73,7 @@ function testContainer() { 'child' => array( '#markup' => 'foo', ), - ), "
\nfoo\n
\n", "#type 'container' with child elements"); + ), "
foo
\n", "#type 'container' with child elements"); } /** diff --git a/core/themes/stable/templates/form/container.html.twig b/core/themes/stable/templates/form/container.html.twig index 0da6c38..72646ce 100644 --- a/core/themes/stable/templates/form/container.html.twig +++ b/core/themes/stable/templates/form/container.html.twig @@ -25,4 +25,12 @@ has_parent ? 'form-wrapper', ] %} -{{ children }} + + {% if errors %} +
+ {{ errors }} +
+ {% endif %} + + {{ children }} +