diff -u b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php --- b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -83,12 +83,12 @@ if ($target_id_data_type === 'integer') { $target_id_definition = DataDefinition::create('integer') - ->setLabel(new TranslationWrapper('@label ID', array($target_type_info->getLabel()))) + ->setLabel(new TranslationWrapper('@label ID', array('@label' => $target_type_info->getLabel()))) ->setSetting('unsigned', TRUE); } else { $target_id_definition = DataDefinition::create('string') - ->setLabel(new TranslationWrapper('@label ID', array($target_type_info->getLabel()))); + ->setLabel(new TranslationWrapper('@label ID', array('@label' => $target_type_info->getLabel()))); } $target_id_definition->setRequired(TRUE); $properties['target_id'] = $target_id_definition; only in patch2: unchanged: --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; +use Drupal\Core\StringTranslation\TranslationWrapper; use Drupal\Core\Language\LanguageInterface; use Drupal\entity_reference\Tests\EntityReferenceTestTrait; use Drupal\entity_test\Entity\EntityTest; @@ -111,6 +112,10 @@ public function testContentEntityReferenceItem() { $this->assertEqual($entity->field_test_taxonomy_term->entity->getName(), $this->term->getName()); $this->assertEqual($entity->field_test_taxonomy_term->entity->id(), $tid); $this->assertEqual($entity->field_test_taxonomy_term->entity->uuid(), $this->term->uuid()); + // Verify that the label for the target ID property definition is correct. + $label = $entity->field_test_taxonomy_term->getFieldDefinition()->getFieldStorageDefinition()->getPropertyDefinition('target_id')->getLabel(); + $this->assertTrue($label instanceof TranslationWrapper); + $this->assertEqual($label->render(), 'Taxonomy term ID'); // Change the name of the term via the reference. $new_name = $this->randomMachineName(); @@ -178,6 +183,10 @@ public function testContentEntityReferenceItemWithStringId() { $storage = \Drupal::entityManager()->getStorage('entity_test'); $storage->resetCache(); $this->assertEqual($this->entityStringId->id(), $storage->load($entity->id())->field_test_entity_test_string_id->target_id); + // Verify that the label for the target ID property definition is correct. + $label = $entity->field_test_taxonomy_term->getFieldDefinition()->getFieldStorageDefinition()->getPropertyDefinition('target_id')->getLabel(); + $this->assertTrue($label instanceof TranslationWrapper); + $this->assertEqual($label->render(), 'Taxonomy term ID'); } /**