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.