diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php index 08a5252..cf1059d 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\entity_reference\Plugin\Type\SelectionPluginManager; +use Drupal\field\FieldInstanceConfigInterface; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; /** @@ -85,7 +86,12 @@ public function getMatches(FieldDefinitionInterface $field_definition, $entity_t if (isset($string)) { // Get an array of matching entities. - $widget = entity_get_form_display($entity_type, $field_definition->bundle, 'default')->getComponent($field_definition->getName()); + if ($field_definition instanceof FieldInstanceConfigInterface) { + $widget = $field_definition->getDisplayOptions('form'); + } + else { + $widget = entity_get_form_display($entity_type, $field_definition->bundle, 'default')->getComponent($field_definition->getName()); + } $match_operator = !empty($widget['settings']['match_operator']) ? $widget['settings']['match_operator'] : 'CONTAINS'; $entity_labels = $handler->getReferenceableEntities($string, $match_operator, 10);