diff --git a/core/includes/form.inc b/core/includes/form.inc index a8688f26c5..067eaaa7ab 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -442,7 +442,7 @@ function template_preprocess_form_element(&$variables) { '#title_display' => 'before', '#wrapper_attributes' => [], '#label_attributes' => [], - '#label_for' => [], + '#label_for' => NULL, ]; $variables['attributes'] = $element['#wrapper_attributes']; diff --git a/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php b/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php index 8710171528..80b031ef08 100644 --- a/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php @@ -210,6 +210,20 @@ public function testDescriptionDefaultFileFieldDisplay() { // Load uncached node. \Drupal::entityTypeManager()->getStorage('node')->resetCache([$nid]); $node = Node::load($nid); + + // Test default formatter. + $this->drupalGet('node/' . $nid); + $this->assertFieldByXPath('//a[@href="' . $node->{$field_name}->entity->url() . '"]', $description); + + // Change formatter to "Table of files". + $display = \Drupal::entityTypeManager()->getStorage('entity_view_display')->load('node.' . $type_name . '.default'); + $display->setComponent($field_name, [ + 'label' => 'hidden', + 'type' => 'file_table', + ])->save(); + + $this->drupalGet('node/' . $nid); + $this->assertFieldByXPath('//a[@href="' . $node->{$field_name}->entity->url() . '"]', $description); } /**