I needed functionality for Entity Reference Autocomplete module so I wrote a patch to support it. The author is writing the tags we need and we just need to alter it.
See https://www.drupal.org/node/2353169#comment-10357499
If anyone has a better way to do this let me know.
Patch Incoming.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | realname-entity-reference-autocomplete-2572691-6.patch | 1.42 KB | jalpesh |
| #10 | autocomplete_style_tags.png | 21.15 KB | shevgeny |
| #10 | autocomplete.png | 19.23 KB | shevgeny |
| #6 | realname-entity-reference-autocomplete-2572691-5.patch | 1.38 KB | Derimagia |
Comments
Comment #2
Derimagia commentedAdding patch.
Comment #3
Derimagia commentedComment #4
nancydruFirst, there is no check for the existence of the Entity Reference Autocomplete module, so those who don't use that would encounter a failure with this.
Second, the usual response to stuff like this is "We do not put in module-specific support; modules should largely be agnostic about other modules."
I don't really understand the problem to be solved here. Can they not just do a
format_username()?Comment #5
Derimagia commented1) It's in a hook_query_tag_ALTER so if the tag never gets added this code won't get called. Adding a module_exists wouldn't hurt.
2) This is kind of difficult because even though I understand this the code should exist somewhere, don't you think? If entity reference autocomplete adds it then they will have module specific code in there module. How else would you add this functionality?
3) Entity Reference Autocomplete has an autocomplete that let's you search based off of a name. By default this will only do their username, not their rename. So if the name is "John Doe" but there username is "jd123" and you search for "John" the user won't come up without this patch.
Agreed the patch needs work (The tag changed at the very least) though.
Comment #6
Derimagia commentedUpdating patch to add module_exists (just to be sure) and then updating tag used. Let me know if you need anything else.
Comment #7
nancydruThanks. I would like some other eyes on this.
Comment #8
da_cloud commentedJust installed the above patch on one of our sites that uses both the realname module and the entityreference_autocomplete and I can confirm that the above patch works like a charm.
Comment #9
hass commentedComment #10
shevgenyI have not worked your patch.
When I select a widget "Autocomplete" to refer to the user - everything is OK, the search is carried out on the actual user name. However, when choosing under the same conditions widget "Autocomplete style tags", the search is carried out exclusively by login and user id.
Autocomplete:

Autocomplete style tags:

Comment #11
antoinetooley commentedHi,
I am getting this error when using this patch with an authenticated user:
Recoverable fatal error: Method DatabaseCondition::__toString() must return a string value in realname_query_era_query_alter() (line 454
Any ideas?
It works great with the user number 1 which I love
Comment #12
antoinetooley commentedHi again,
I figured out the problem, which was to add an is_string check:
I hope that helps someone.
Thanks!
Comment #13
Derimagia commentedAwesome thanks for the feedback. I'll fix the patch when I have some time. I haven't looked into this for a while, what is adding a non-string to it? Sounds like a sub condition is being added somewhere.
Comment #14
jalpesh commentedI agree with @Derimagia on comment #5, where it is good to have support of other module. I have update the path as per suggestion in comment #12.