diff -u b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php --- b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php +++ b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php @@ -4,5 +4,6 @@ use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Tags; +use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface; use Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface; @@ -130,7 +131,7 @@ // Put entity into settings. $form_object = $form_state->getFormObject(); - if (isset($form_object)) { + if (isset($form_object) && $form_object instanceof EntityForm) { $entity = $form_object->getEntity(); if (isset($entity)) { $storage = $form_state->getStorage();