diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index 1e5fa7f..b5378cd 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -236,7 +236,7 @@ public function isEmpty() { public function preSave() { if ($this->hasNewEntity()) { $this->entity->save(); - $this->set('target_id', $this->entity->id(), FALSE); + $this->target_id = $this->entity->id(); } // Handle the case where an unsaved entity was directly set using the public // 'entity' property and then saved before this entity. In this case diff --git a/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/LinkFormatter.php index f14eb91..64bf4e6 100644 --- a/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/LinkFormatter.php +++ b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/LinkFormatter.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Component\Utility\String; +use Drupal\taxonomy\Plugin\Field\FieldType\TaxonomyTermReferenceItem; /** * Plugin implementation of the 'taxonomy_term_reference_link' formatter. @@ -31,7 +32,7 @@ public function viewElements(FieldItemListInterface $items) { // Terms without target_id do not exist yet, theme such terms as just their // name. foreach ($items as $delta => $item) { - if (!$item->target_id) { + if ($item->target_id === TaxonomyTermReferenceItem::NEW_ENTITY_MARKER) { $elements[$delta] = array( '#markup' => String::checkPlain($item->entity->label()), );