diff --git a/core/modules/system/src/Tests/Form/ElementsLabelsTest.php b/core/modules/system/src/Tests/Form/ElementsLabelsTest.php index 9a09442..ed42b8d 100644 --- a/core/modules/system/src/Tests/Form/ElementsLabelsTest.php +++ b/core/modules/system/src/Tests/Form/ElementsLabelsTest.php @@ -101,6 +101,13 @@ function testFormLabels() { function testFormDescriptions() { $this->drupalGet('form_test/form-descriptions'); + // Check #description placement with no #description_display, so default is + // 'after' the form item. + $field_id = 'edit-form-textfield-test-description-default'; + $description_id = $field_id . '--description'; + $elements = $this->xpath('//input[@id="' . $field_id . '" and @aria-describedby="' . $description_id . '"]/following-sibling::div[@id="' . $description_id . '"]'); + $this->assertTrue(isset($elements[0]), t('Properly places by default the #description element after the form item.')); + // Check #description placement with #description_display='after'. $field_id = 'edit-form-textfield-test-description-after'; $description_id = $field_id . '--description'; diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php index df4cce5..6479d2b 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php @@ -28,6 +28,12 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { + $form['form_textfield_test_description_default'] = array( + '#type' => 'textfield', + '#title' => 'Textfield test for description default after element', + '#description' => 'Textfield test for description default after element', + ); + $form['form_textfield_test_description_before'] = array( '#type' => 'textfield', '#title' => 'Textfield test for description before element',