Since upgrading from EntityReference 7.x-1.0 to EntityReference 7.x-1.1, the autocomplete on an entity reference field used to reference users via their profile name has stopped working.
After some debugging, I think I have traced this change in behaviour down to this commit:
http://cgit.drupalcode.org/entityreference/commit/?id=8cbef5ee410b36ca1d...
After stepping through the code with a debugger a few times, I am still none the wiser as to why this code breaks our autocomplete view.
For background, the entityreference view is a user view with a relationship to the user profile entity (profile2), so we can pull through the firstname, lastname etc. and search on these values. Reading through the code and the issue it came from, it appears that this commit was intended to actually fix this issue, rather than cause it.
So for our needs, we would like to use the 7.x-1.1 release, as it is a security release and includes other fixes, but would like to remove this commit, so I'll attach a patch that does that. This patch is mainly for our own needs, but may help someone else in the same situation, and will hopefully prompt some further discussion about why the original commit causes the problem in the first place.
Comment | File | Size | Author |
---|---|---|---|
#1 | fix-autocomplete-entity-reference-on-user-profile-fields-2293437.patch | 1.15 KB | Finn Lewis |
Comments
Comment #1
Finn Lewis CreditAttribution: Finn Lewis commentedComment #2
brogdawg CreditAttribution: brogdawg commentedThe patch did fix the problem where searching by profile fields breaks all autocomplete results (https://www.drupal.org/node/1898290#comment-7047750), but I still can't reference users by the profile fields. For example I can start typing a username or user email and it finds the results and displays the profile first and last name but if I try typing in the last name I get no results. In my entity reference view I am searching on all fields, username, user email, profile first and last name.
Is this not the behavior you are experiencing?
Comment #3
nithinkolekar CreditAttribution: nithinkolekar commentedComment #4
zterry95 CreditAttribution: zterry95 commentedconfirm this patch works for me.
Comment #5
zterry95 CreditAttribution: zterry95 commentedsorry for update the status carelessly.
this patch fix the autocomplete issue for profile2; but did not fix the problem of searching by the profile2 field.
Comment #6
supriyarajgopal CreditAttribution: supriyarajgopal commentedSubscribing
Comment #7
supriyarajgopal CreditAttribution: supriyarajgopal commentedPatch in #8 in https://www.drupal.org/node/1898290 worked for me with the latest dev version of this module.
Regards,
Supriya Rajgopal