summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-08-29 07:10:50 -0500
committerAlex Pott2016-08-29 07:10:58 -0500
commit5e92fad91f149a5e78b0d2bf30748371ad62eb53 (patch)
treeb035a8ccea11d7de35ccb05fba494ce11828b1ff
parenta55f7a2538d347ce2a4bdd4f1a026058b63b11b7 (diff)
Issue #2788343 by mikeker: Entity Reference error message has "@value (@id)" in it
(cherry picked from commit 06da519507332138db6b1f82d4c3d539bdc818a3)
-rw-r--r--core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php2
-rw-r--r--core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php10
2 files changed, 11 insertions, 1 deletions
diff --git a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
index 23fd0b5..51adf91 100644
--- a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
+++ b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
@@ -297,7 +297,7 @@ class EntityAutocomplete extends Textfield {
$multiples[] = $name . ' (' . $id . ')';
}
$params['@id'] = $id;
- $form_state->setError($element, 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))));
+ $form_state->setError($element, 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));
}
else {
// Take the one and only matching entity.
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
index d781084..4e8be4b 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
@@ -208,6 +208,7 @@ class EntityReferenceAdminTest extends WebTestBase {
'id' => 'node_test_view',
'label' => 'Node Test View',
'show[wizard_key]' => 'node',
+ 'show[sort]' => 'none',
'page[create]' => 1,
'page[title]' => 'Test Node View',
'page[path]' => 'test/node/view',
@@ -221,6 +222,14 @@ class EntityReferenceAdminTest extends WebTestBase {
'style_options[search_fields][title]' => 'title',
);
$this->drupalPostForm(NULL, $edit, t('Apply'));
+
+ // Set sort to NID ascending.
+ $edit = [
+ 'name[node_field_data.nid]' => 1,
+ ];
+ $this->drupalPostForm('admin/structure/views/nojs/add-handler/node_test_view/entity_reference_1/sort', $edit, t('Add and configure sort criteria'));
+ $this->drupalPostForm(NULL, NULL, t('Apply'));
+
$this->drupalPostForm('admin/structure/views/view/node_test_view/edit/entity_reference_1', array(), t('Save'));
$this->clickLink(t('Settings'));
@@ -301,6 +310,7 @@ class EntityReferenceAdminTest extends WebTestBase {
$this->assertText(t('Multiple entities match this reference;'));
$this->assertText(t("@node1", ['@node1' => $node1->getTitle() . ' (' . $node1->id() . ')']));
$this->assertText(t("@node2", ['@node2' => $node2->getTitle() . ' (' . $node2->id() . ')']));
+ $this->assertText(t('Specify the one you want by appending the id in parentheses, like "@example".', ['@example' => $node2->getTitle() . ' (' . $node2->id() . ')']));
$edit = array(
'title[0][value]' => 'Test',