diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php index 07ec8cd..4dcbafa 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php +++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php @@ -289,17 +289,18 @@ public function validateAutocompleteInput($input, &$element, FormStateInterface $params = array( '%value' => $input, '@value' => $input, + '@type' => $element['#target_type'] . 's', ); if (empty($entities)) { if ($strict) { // Error if there are no entities available for a required field. - $form_state->setError($element, $this->t('There are no entities matching "%value".', $params)); + $form_state->setError($element, $this->t('There are no @type matching "%value".', $params)); } } elseif (count($entities) > 5) { $params['@id'] = key($entities); // Error if there are more than 5 matching entities. - $form_state->setError($element, $this->t('Many entities are called %value. Specify the one you want by appending the id in parentheses, like "@value (@id)".', $params)); + $form_state->setError($element, $this->t('Many @type are called %value. Specify the one you want by appending the id in parentheses, like "@value (@id)".', $params)); } elseif (count($entities) > 1) { // More helpful error if there are only a few matching entities. @@ -308,7 +309,8 @@ public function validateAutocompleteInput($input, &$element, FormStateInterface $multiples[] = $name . ' (' . $id . ')'; } $params['@id'] = $id; - $form_state->setError($element, $this->t('Multiple entities match this reference; "%multiple". Specify the one you want by appending the id in parentheses, like "@value (@id)".', array('%multiple' => implode('", "', $multiples)))); + $params['%multiple'] = implode('", "', $multiples); + $form_state->setError($element, $this->t('Multiple @type match this reference; "%multiple". Specify the one you want by appending the id in parentheses, like "@value (@id)".', $params)); } else { // Take the one and only matching entity. diff --git a/core/modules/node/src/Tests/PageEditTest.php b/core/modules/node/src/Tests/PageEditTest.php index b2d818b..e338cd8 100644 --- a/core/modules/node/src/Tests/PageEditTest.php +++ b/core/modules/node/src/Tests/PageEditTest.php @@ -12,7 +12,7 @@ * * @group node */ -class PageEditTest extends NodeTestBase { + class PageEditTest extends NodeTestBase { protected $webUser; protected $adminUser; @@ -110,7 +110,7 @@ function testPageAuthoredBy() { 'uid[0][target_id]' => 'invalid-name', ); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); - $this->assertRaw(t('There are no entities matching "%name".', array('%name' => 'invalid-name'))); + $this->assertRaw(t('There are no users matching "%name".', array('%name' => 'invalid-name'))); // Change the authored by field to the anonymous user (uid 0). $edit['uid[0][target_id]'] = 'Anonymous (0)'; diff --git a/core/modules/system/src/Tests/Entity/Element/EntityAutocompleteElementFormTest.php b/core/modules/system/src/Tests/Entity/Element/EntityAutocompleteElementFormTest.php index 1fcdb72..a956c1c 100644 --- a/core/modules/system/src/Tests/Entity/Element/EntityAutocompleteElementFormTest.php +++ b/core/modules/system/src/Tests/Entity/Element/EntityAutocompleteElementFormTest.php @@ -250,7 +250,7 @@ public function testInvalidEntityAutocompleteElement() { ]); $form_builder->submitForm($this, $form_state); $this->assertEqual(count($form_state->getErrors()), 1); - $this->assertEqual($form_state->getErrors()['single'], t('There are no entities matching "%value".', array('%value' => 'single - non-existent label'))); + $this->assertEqual($form_state->getErrors()['single'], t('There are no entity_tests matching "%value".', array('%type' => 'entity_test','%value' => 'single - non-existent label'))); // Test 'single' with a entity ID that doesn't exist. $form_state = (new FormState()) @@ -273,7 +273,7 @@ public function testInvalidEntityAutocompleteElement() { // The element without 'autocreate' support still has to emit a warning when // the input doesn't end with an entity ID enclosed in parentheses. $this->assertEqual(count($form_state->getErrors()), 1); - $this->assertEqual($form_state->getErrors()['single_no_validate'], t('There are no entities matching "%value".', array('%value' => 'single - non-existent label'))); + $this->assertEqual($form_state->getErrors()['single_no_validate'], t('There are no entity_tests matching "%value".', array('%type' => 'entity_test', '%value' => 'single - non-existent label'))); $form_state = (new FormState()) ->setValues([