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

Comments

ahillio’s picture

StatusFileSize
new12.64 KB
new36.77 KB

Oh, 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.

ahillio’s picture

StatusFileSize
new24.15 KB

In 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.

ahillio’s picture

Previously I was unsure whether they were the first ten or some arbitrary ten -- confirming that they indeed are the first ten.

robmc’s picture

Status: Active » Needs review
StatusFileSize
new1.16 KB

The 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

levelos’s picture

Status: Needs review » Needs work

I believe the best way to handle this is to implement the EntityReference_SelectionHandler interface. E.g., http://drupalcode.org/project/redhen.git/blob/HEAD:/modules/redhen_org_g....

robmc’s picture

Much cleaner, I like it. When I get a bit I'll re-work the solution. Thanks!

Best Regards,

Rob

levelos’s picture

Category: Bug report » Feature request
Issue summary: View changes
ahillio’s picture

I'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...?

johnkingeu’s picture

There 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?

nadavoid’s picture

StatusFileSize
new2.57 KB

Attaching 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.

nadavoid’s picture

nadavoid’s picture

StatusFileSize
new1.99 KB

Better patch attached.

nadavoid’s picture

The 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.

levelos’s picture

Status: Needs work » Fixed

Thanks David!

  • levelos committed 7df8e79 on 7.x-1.x authored by nadavoid
    Issue #2085279 by nadavoid, robmc: Autocomplete limited to first entries...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.