diff --git a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php index 495ebc0..7eaa293 100644 --- a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php +++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php @@ -736,8 +736,12 @@ class InlineParagraphsWidget extends WidgetBase { } else { // @todo: properize this. - $add_text = 'No @title_multiple have been added yet. Select a @title type and press the button below to add one.'; - $element_text = '

' . t($add_text, array('@title_multiple' => $this->getSetting('title_plural'), '@title' => $this->getSetting('title'))) . '

'; + if (count($access_options) == 1) { + $element_text = '

' . t('No @title has been added yet.', ['@title' => $this->getSetting('title')]) . '

'; + } + else { + $element_text = '

' . t('No @title has been added yet. Select a @title type and press the button below to add one.', ['@title' => $this->getSetting('title')]) . '

'; + } $element_text .= $description ? '
' . $description . '
' : ''; $elements += array( diff --git a/src/Tests/ParagraphsAdministrationTest.php b/src/Tests/ParagraphsAdministrationTest.php index ecfb9a2..63148f5 100644 --- a/src/Tests/ParagraphsAdministrationTest.php +++ b/src/Tests/ParagraphsAdministrationTest.php @@ -569,6 +569,21 @@ class ParagraphsAdministrationTest extends WebTestBase { $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_confirm_remove'); $this->drupalPostForm(NULL, [], t('Save and keep published')); $this->assertText('choke test has been updated.'); + + // Verify that the text displayed is correct when we have multiple + // paragraph types. + $this->drupalGet('node/add/article'); + $this->assertText('No Paragraph has been added yet. Select a Paragraph type and press the button below to add one.'); + + // Remove 2 of the 3 paragraph types and verify that the text displayed is + // correct. + $this->drupalGet('admin/structure/paragraphs_type'); + $this->clickLink('Delete'); + $this->drupalPostForm(NULL, [], t('Delete')); + $this->clickLink('Delete'); + $this->drupalPostForm(NULL, [], t('Delete')); + $this->drupalGet('node/add/article'); + $this->assertText('No Paragraph has been added yet.'); } /**