diff --git a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php index 48bd6f4..cbed4ff 100644 --- a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php +++ b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php @@ -251,6 +251,10 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $element['uri']['#description'] = $element['#description']; } else { + // If we have the description of the type of field together with + // the user provided description, we want to make a distinction + // between "core help text" and "user entered help text". To make + // this distinction more clear, we separate them with a line break. $element['uri']['#description'] .= '
' . $element['#description']; } } diff --git a/core/modules/link/src/Tests/LinkFieldUITest.php b/core/modules/link/src/Tests/LinkFieldUITest.php index 109475b..d9a7a7a 100644 --- a/core/modules/link/src/Tests/LinkFieldUITest.php +++ b/core/modules/link/src/Tests/LinkFieldUITest.php @@ -85,6 +85,11 @@ function testFieldUI() { LinkItemInterface::LINK_GENERIC, LinkItemInterface::LINK_INTERNAL, ]; + $help_texts = [ + LinkItemInterface::LINK_EXTERNAL => 'This must be an external URL such as http://example.com.', + LinkItemInterface::LINK_GENERIC => 'You can also enter an internal path such as /node/add or an external URL such as http://example.com. Enter <front> to link to the front page.', + LinkItemInterface::LINK_INTERNAL => rtrim(\Drupal::url('', array(), array('absolute' => TRUE)), '/'), + ]; $field_count = 0; // Test all variations of link types on all cardinalities. foreach ($cardinalities as $cardinality) { @@ -126,32 +131,24 @@ function testFieldUI() { $this->drupalGet($add_path); // Check that the help texts we assume should be there, is there. - switch ($link_type) { - case LinkItemInterface::LINK_GENERIC: - // Check that the text for allowing both internal and external - // is present. - $this->assertRaw('You can also enter an internal path such as /node/add or an external URL such as http://example.com.'); - break; - - case LinkItemInterface::LINK_EXTERNAL: - // Check the external only link help text. - $this->assertRaw('This must be an external URL such as http://example.com.'); - break; - - case LinkItemInterface::LINK_INTERNAL: - // Internal links have no "system" description. Test that none - // of the above shows here. - $this->assertNoRaw('This must be an external URL such as http://example.com.'); - $this->assertNoRaw('You can also enter an internal path such as /node/add or an external URL such as http://example.com.'); - // And assert that the field prefix is the internal URL. - $this->assertRaw(rtrim(\Drupal::url('', array(), array('absolute' => TRUE)), '/')); - break; - + $this->assertRaw($help_texts[$link_type]); + if ($link_type === LinkItemInterface::LINK_INTERNAL) { + // Internal links have no "system" description. Test that none + // of the other help texts show here. + $this->assertNoRaw($help_texts[LinkItemInterface::LINK_EXTERNAL]); + $this->assertNoRaw($help_texts[LinkItemInterface::LINK_GENERIC]); } // Also assert that the description we made is here, no matter what // the cardinality or link setting. if ($description_enabled) { $this->assertRaw($description); + // If the link type was not internal, and the cardinalyty was 1, + // and the title setting was 0, we also check that the field type + // help text and the user entered description appear with a
+ // separating them. + if (!$title_setting && $cardinality === 1 && $link_type != LinkItemInterface::LINK_INTERNAL) { + $this->assertRaw($help_texts[$link_type] . '
' . $description); + } } } } diff --git a/core/modules/menu_link_content/src/Tests/MenuLinkContentFormTest.php b/core/modules/menu_link_content/src/Tests/MenuLinkContentFormTest.php index 7bb8990..33cb4e7 100644 --- a/core/modules/menu_link_content/src/Tests/MenuLinkContentFormTest.php +++ b/core/modules/menu_link_content/src/Tests/MenuLinkContentFormTest.php @@ -41,7 +41,7 @@ public function testMenuLinkContentForm() { $element = $this->xpath('//select[@id = :id]/option[@selected]', array(':id' => 'edit-menu-parent')); $this->assertTrue($element, 'A default menu parent was found.'); $this->assertEqual('admin:', $element[0]['value'], ' menu is the parent.'); - // Test the field description is present. + // Test that the field description is present. $this->assertRaw('The location this menu link points to.'); $this->drupalPostForm(