I've updated to the latest dev and run update.php -- contacts were originally imported with feeds import and redhen_contacts 7.x-1.3
Steps to reproduce:
Have redhen_contacts filled with contacts - we have approximately 1800 contacts.
Make a field of type Entity Reference and select Autocomplete for the widget.
Set the target type to Contact and select the Target bundle and leave the Sort by set to the default of "Don't Sort"
Save content type.
Try to use the autocomplete to associate contact and you will find the first 10 contacts entered will show no matter what is entered for the search criteria in the autocomplete field.
Happy to provide any details that may help.
Best Regards,
Rob McCrea
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | autocomplete_filter-2085279-12.patch | 1.99 KB | nadavoid |
| #4 | 2085279-entityreference_autocomplete.patch | 1.16 KB | robmc |
| #2 | Workspace 1_042.png | 24.15 KB | ahillio |
| #1 | contacts-list.png | 36.77 KB | ahillio |
| #1 | entity-reference.png | 12.64 KB | ahillio |
Comments
Comment #1
ahillio commentedOh, I'm seeing something similar. I'm not sure if the entity reference field is only getting the first 10 contacts in the autocomplete, but of the contacts that it is getting it's missing the one I'm typing. In the screenshot I'm trying to reference the contact (created not from feeds import but by using devel_generate and a rule to create contact when new user account is saved) named driwuwip and I type "driw" but the contact is not listed and contacts that don't include the characters I typed are listed.
Comment #2
ahillio commentedIn a contact reference field on an entity registration form, I tried registering and typed in a name that there's no contact for.
Got this error:
Multiple entities match this reference; "Array (basic_contact_type)", "Array (person)"The error message is wrong; no contact entities exist that match what I entered, but the machine says that multiple ones do match.
Does this shed any light on the issue?
Someone else ran into this issue at https://drupal.org/node/1751620#comment-6403090 - we're not the only ones ;)
And work-around (in case someone is looking for this) is changing widget type from autocomplete to select list, though selectlist isn't very nice.
Comment #3
ahillio commentedPreviously I was unsure whether they were the first ten or some arbitrary ten -- confirming that they indeed are the first ten.
Comment #4
robmc commentedThe generic entityreference was not aware of the specific contact fields when doing the search. This patch modifies the entityreference query to search the first, middle and last name for anything typed in for the search criteria.
Hope it helps!
Best Regards,
Rob
Comment #5
levelos commentedI believe the best way to handle this is to implement the
EntityReference_SelectionHandlerinterface. E.g., http://drupalcode.org/project/redhen.git/blob/HEAD:/modules/redhen_org_g....Comment #6
robmc commentedMuch cleaner, I like it. When I get a bit I'll re-work the solution. Thanks!
Best Regards,
Rob
Comment #7
levelos commentedComment #8
ahillio commentedI've been using that patch from #4 since October and it fixes the entityreference autocomplete widget. Thanks Rob!!!
It does not fix autocomplete in the Inline Entity Form widget when you allow users to add existing contacts. I wonder if Lev's suggestion would fix both...?
Comment #9
johnkingeu commentedThere seem to be quite a few comments and feature requests regarding the ability to add RedHen contacts to nodes via Entity Reference.
For example:
https://drupal.org/node/1751620 Make RedHen compatible with Entity Connect #1751620: Make RedHen compatible with Entity Connect
https://drupal.org/node/1854940 Add support in RedHen Contact module for Inline Entity Forms
https://drupal.org/node/2178649 enable entityreference field that's hardcoded by Redhen module to work with entityreference_prepopulate
Given the importance of being able to connect RedHen entities to content nodes, I vote that we raise this to Major importance - anyone agree / disagree?
Comment #10
nadavoid commentedAttaching a patch that extends EntityReference's default filtering, so that contacts are filtered by first name.
I also added a comment about adding a tag or metadata so that an OR condition can be added, filtering by first, middle, or last name. This would be much like the patch in #4, with the added benefit that it would be controlled by the EFQ, not the URL.
Comment #11
nadavoid commentedComment #12
nadavoid commentedBetter patch attached.
Comment #13
nadavoid commentedThe philosophy of RedHen is to have minimal dependencies, but it is probably worth noting that you can use views to populate and filter the entityreference field. Create an entityreference display in a view that lists contacts, add first, middle, and last name fields, and select them as search fields. Then in the field settings of the entityreference field, you will have the ability to select the view. Still, it would be great to have this autocomplete filter work natively, without depending on views.
Comment #14
levelos commentedThanks David!