Loading src/Element/EntityIdAutocomplete.php +7 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,9 @@ namespace Drupal\autocomplete_id\Element; use Drupal\Component\Utility\Tags; use Drupal\Core\Entity\Element\EntityAutocomplete; use Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface; Loading Loading @@ -169,13 +171,15 @@ class EntityIdAutocomplete extends EntityAutocomplete { * Value of a matching entity ID, or NULL if none. */ protected static function matchEntityById(SelectionInterface $handler, $input, array &$element, FormStateInterface $form_state, $strict) { $entities = \Drupal::entityTypeManager()->getStorage($element['#target_type'])->loadByProperties(['id' => $input]); $entity_type_manager = \Drupal::entityTypeManager(); $entity_type = $entity_type_manager->getDefinition($element['#target_type']); $entity_id_key = $entity_type->getKey('id'); $entities = $entity_type_manager->getStorage($element['#target_type'])->loadByProperties([$entity_id_key => $input]); $params = [ '%value' => $input, '@value' => $input, '@entity_type_plural' => \Drupal::entityTypeManager()->getDefinition($element['#target_type'])->getPluralLabel(), '@entity_type_plural' => $entity_type->getPluralLabel(), ]; if (empty($entities)) { if ($strict) { Loading Loading
src/Element/EntityIdAutocomplete.php +7 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,9 @@ namespace Drupal\autocomplete_id\Element; use Drupal\Component\Utility\Tags; use Drupal\Core\Entity\Element\EntityAutocomplete; use Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface; Loading Loading @@ -169,13 +171,15 @@ class EntityIdAutocomplete extends EntityAutocomplete { * Value of a matching entity ID, or NULL if none. */ protected static function matchEntityById(SelectionInterface $handler, $input, array &$element, FormStateInterface $form_state, $strict) { $entities = \Drupal::entityTypeManager()->getStorage($element['#target_type'])->loadByProperties(['id' => $input]); $entity_type_manager = \Drupal::entityTypeManager(); $entity_type = $entity_type_manager->getDefinition($element['#target_type']); $entity_id_key = $entity_type->getKey('id'); $entities = $entity_type_manager->getStorage($element['#target_type'])->loadByProperties([$entity_id_key => $input]); $params = [ '%value' => $input, '@value' => $input, '@entity_type_plural' => \Drupal::entityTypeManager()->getDefinition($element['#target_type'])->getPluralLabel(), '@entity_type_plural' => $entity_type->getPluralLabel(), ]; if (empty($entities)) { if ($strict) { Loading