Closed yorkshire-pudding closed 1 month ago
@yorkshire-pudding I don't think, this is anything that can be addressed in this module.
The message stems from core/modules/entityreference/plugins/selection/EntityReferenceSelectionHandlerGeneric.inc
Can you check your settings for this entity reference field?
Is the field setting Hide IDs
checked? If so, can you uncheck it and try again?
EDIT: ah, wait, that setting's actually unrelated. The whole handling of this entity seems a bit quirky with entityreference. It's unclear to me, when the ids are attached and when not. But when ids are attached, the field works. And it always works when it's a select list (field widget). Hm... a core bug?
Some quick findings (maybe related, maybe not...). The label_key property is hardcoded for core entities in EntityReferenceSelectionHandlerGeneric.inc, that's why search matching with autocomplete doesn't work at all.
But... we might be able to provide something with a class extending EntityReferenceSelectionHandlerGeneric.
Again: only autocomplete misbehaves, select list works just fine.
Yes, it seems to be as simple as that: set the label_key to "name". :wink:
Another thing that came to my mind: do I have to add a permission check in my handler extension? Or is that done automatically? entity_access is called in EntityReferenceSelectionHandlerGeneric, so that check seems correct.
Anyway, @yorkshire-pudding does this fix the problem for you, or is this just an unrelated fix and the problem (missing ID with autocomplete) persists for you?
@indigoxela - Yes I had also found that select lists worked fine and that was going to be my workaround. However, your PR completely fixes it. Thank you 😄
Steps to reproduce
Expected result Node saves with no issues
Actual result Validation error like: Many entities are called Filter Perms. Specify the one you want by appending the id in parentheses, like "Filter Perms (1)"
Never seen this on other ER fields