It might be a nice feature of this "extended" module to add another option to allow a user to hide the Node ID from an autocomplete result.
So, instead of "My Node (1)", it would just show "My Node" as the result.

Currently, there's a few ways to accomplish this, each requiring their own mini module to do it.

https://www.bounteous.com/insights/2019/01/30/drupal-how-customize-autoc...

https://www.chapterthree.com/blog/how-alter-entity-autocomplete-results-...

I've even gone down the route of creating a new class extending from EntityAutocomplete, then in the ->getEntityLabels() method, I adjust the label such as:

$label .= ' (' . $last_revision_state . ') (' . $entity->id() . ')';

In that case, i had logic that looks up the current moderation state of the node and appended it to the label, but at that point, the Node ID could be removed from the result.

The only concern I have with removing the Node ID is, does Drupal need that Node ID to keep track of what item is selected?

Anyhow, I think instead of these various ways of doing the removal of the Node ID (if it's safe to remove the Node ID), it would be a nice feature to include in this module to remove it.

Comments

joshua.boltz created an issue. See original summary.

godotislate’s picture

Status: Active » Closed (won't fix)

I had some thoughts originally on some other functionality to extend the entity autocomplete widget, but they were more complex than anticipated, and I did not have the time to implement. I don't have objections to this feature request if anyone wants to put in a patch, but given the release of Drupal 8.8, and my general lack of time to work on this anymore, I'm marking this module as deprecated and unmaintained.