When I create/edit a node, the referenced data displays as expected when Select List is chosen but if I change the widget to Autocomplete it doesn't work; and in the example I give below, that is the only change I make. The autocomplete widget graphic just spins a few times then stops.

I tried the dev version of Entity reference with Entity API 1.0, then tried the dev version of Entity API with Entity reference 1.0, then tried the dev versions of both.

There are three main node content types involved. A, B, C. Instead of showing the relationship between A and C directly, I do it through nodes of content type B. CCK B contains entity reference fields to both A and C.

There has been no problem with autocomplete pulling up an entity reference to node type A or C from within B.

And at first I used Entity reference autocomplete during creation/editing of node type A to find the right node of type B, but I immediately noticed it was showing ALL node type B's and not just the ones which contained the specific entity (node ID) I was working with. So I realized I should try adding a display to one of my existing views.

I had already built a View to be a block on a node type A pages to show that node's relationships (described in node type B) to various C nodes. I used the directions here: http://drupal.org/node/1841004 and it worked fine. The block on node type A only showed relationships described through node type Bs to node Cs.

So I added an Entity Reference Display to the Views I'd created. Both Format and Show have all items checked in their Settings options. (As an aside, I have read many issues in various queues. Since I am also using http://drupal.org/project/auto_entitylabel I am not worried about searching — autocomplete — the title of the nodes vs. the fields; the nodes have already been titled with the information from the fields I consider vital and am searching for.)

With the additional Entity Reference Display added to my View I configured it in the Entity Selection area of the Field Settings tab in my Entity reference field on my custom content type. (Thus filtering all nodes of type B to only show those which had a relationship to that specific node of type A.)

I have turned off Views caching and in Performance I have also turned off caching (in addition to clicking the Clear Cache button frequently).

So when I go to create or edit a node of type A or C, trying to locate related nodes of type B, the autocomplete widget fails me. But when I go to Structure > Content Types > A or C > Manage Fields > Widget (for the Entity reference field type) and change the widget type to Select List (instead of autocomplete), they show up perfectly as I expect.

In other words I can go back to my node of type A or C (create or edit) and there in the Entity Reference field is the Select list of the relationship matches of node type B, holding exactly what it should.

Then, without making any other changes, only changing the widget type back to autocomplete instead of Select List, it fails to show any matching nodes. Immediately change it back to Select List and they show up fine.

So, all things being equal, there seems to be a problem with the autocomplete widget. (Although I admit the autocomplete widget in the Entity reference module depends on a number of other modules and ultimately Drupal core, so I can't say exactly where the bug lies.)

Comments

maxplus’s picture

Hi,
I have exact the same problem.
My autocomplete widget does not work when using a View to select the entity.
So also all the modules like Inline Entity form and References Dialog do not work because they all use the Autocomplete widget.

Does anybody have a clue to solve this?

kle’s picture

Hi,
same problem to me: Select list calls the view. Autocomplete-widget does not (Yes, the view is not called!).

technorandall’s picture

Same problem here... I've been trying to figure this out for months!

Exploratus’s picture

Same here. Cant believe this bug is still around.

espurnes’s picture

Any progress on this issue?

Meanwhile I use Select List with Chosen module. Chosen module uses Chosen library and lets search in the select lists.

Maybe it can affect to the performance but it's useful.
I hope it helps.

game’s picture

I think from what you guys are saying im having the reverse issue.

I setup an Entity reference view which basically displays a term and an image (image field added to the terms for an icon). I applied this to my autocomplete widget which works 100% when typing a list is displayed with the term and its image/icon however if I switch to a select list then all I see are the terms with no image :-/ Im also using chosen but I have worked out this isn't an issue with chosen. Anyone else seen this?

Thanks

kopeboy’s picture

Yep, same problems here.
I ended up using a Checkbox/radio buttons widget so no input is required from the user, and still images are displayed... but yes, this need a fix please!

diego.banchero’s picture

Could be a bad design

I found the same problem and I don't know if it's a bug or a bad interface. My views originally had a contextual filter "Content Id from Url". The views was correct but when the views was called by the ajax callback, the url was different as aspected, like this: entityreference/autocomplete/single/field_related_pages/node/nodetype/nid

I moved the contextual filter from "Content Id from Url" to "Raw value from URL" (and selected 7 in the Path component form). Now it works.

howards’s picture

I just ran into this issue in the last day when trying to use the autocomplete field for its user-allowed drag and drop sorting to determine the weights/positions of items in the list. Personally, I am using the patch in #2010898-82: Use tokens for entity selection view arguments to further filter options to a particular group, but it appears the autocomplete field doesn't work while the checkboxes/radio buttons field does.

Additionally, I also tried using the multiple selects widget for testing. When the form is generated (using token supplied contextual filters to views) the items all show up appropriately in a select list. However, adding a new item (using multiple_selects) causes all the fields in that select list to go blank. It appears the issue may lie with something in AJAX.

I have created a small features module to demonstrate the issue, but it requires applying the patch found in #2010898-82: Use tokens for entity selection view arguments to add tokens support to entityreference fields. This particular feature requires og because it is used as a context to limit content options to a particular group. It can also be tested with the multiple selects widget (instead of autocomplete) and it demonstrates the problem in a different way. (To see it work, simply change the widget on Reference Group Content to radio/checkboxes; use the prepopulate links in the add content "description" instead of the actual add content links)

EDIT: Steps to Reproduce

  1. drush site-install -y minimal --account-mail='info@example.org' --account-name='admin' --account-pass='admin' --site-name='EntityReference Autocomplete Fail' --site-mail='info@example.org'
  2. Download and untar/gunzip module in sites/all/modules and then enable. The features module has specific version dependencies on all the modules used, and should fetch the appropriate versions of the modules to reproduce bug, AFAIK.
  3. Apply the patch listed above to entityreference
  4. Create 2 Group nodes
  5. Create as many Group Content nodes as desired
  6. Use the entityreference_prepopulate links to create Reference Group Content nodes. Test the difference between using the autocomplete widget and the checkboxes/radio buttons widget. Radio/Checkboxes have appropriate options while autocomplete never gives appropriate Group Content suggestions.
howards’s picture

StatusFileSize
new3.8 KB

I think this better demonstrates the entityreference issue all on a single page rather than forcing the tester to manually manage field configurations to see the failures. After adding groups and group content, it may require dumping cache to see the references appropriately.

millo_avissar’s picture

subscribe

ChrisValentine’s picture

I've had autocomplete fields suddenly stop working for me in the last couple of months. Normal selector works fine. I started to wonder if it was a browser/JavsScript issue but have tried IE, Chrome and Firefox and they're all the same. No idea what's caused it - chuffin annoying though as the selectors end up being massive and apparently unordered. I've even rolled the site back a month or so in case it was a module update that broke it but its still busted.

Entity Reference 7.x-1.1
Entity reference prepopulate 7.x-1.5
References 7.x-2.1
Views 7.x-3.10

Chris.

Abelito’s picture

StatusFileSize
new1.79 KB

The Autocomplete (Tags style) works, so I took some aspects of that code and applied it to this patch, to get Autocomplete to work.

Abelito’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Active » Needs review

Status: Needs review » Needs work

Abelito’s picture

Any advice about why my patch failed, would be greatly appreciated. :)

Abelito’s picture

StatusFileSize
new917 bytes

This takes us part way there... it fixes the issue except when the field is has multiple values.

dca123’s picture

Subscribe

Abelito’s picture

Status: Needs work » Needs review

There is a conflict with the Real Name module. This patch for RealName fixes the issue: https://www.drupal.org/node/985944#comment-10069094

Status: Needs review » Needs work
Abelito’s picture

Status: Needs work » Needs review

This RealName patch works too, and it looks more likely to make it into the RealName module: https://www.drupal.org/node/2261665#comment-10513164

wickwood’s picture

We also have this problem, but curiously just changing the widget to Autocomplete (Tags style) solves the problem as well. The problem seems to only exists with plain Autocomplete.

We also have the Real Name Module installed, but I have not applied any of the patches suggested above.

Thanks for the help!
Steve

NewZeal’s picture

I had the same problem and solved it using Autocomplete (Tags style). Thanks wickwood.

wickwood’s picture

You welcome, New Zeal! Glad that little discovery worked for you, too.

supriyarajgopal’s picture

Patch in #8 in https://www.drupal.org/node/1898290 worked for me with the latest dev version of this module.

Regards,
Supriya Rajgopal

heddn’s picture

Assigned: Unassigned » heddn

Working on a patch.

heddn’s picture

Assigned: heddn » Unassigned

Un-assigning. I cannot reproduce the specific error on this site. I have been able to on others, so I'm not sure what is going on here.

StG’s picture

I have been struggling with this issue for some days without any luck. I have a thesis content type with tow entity reference fields (author and reviewer), they are referring to a subset of users created by entity reference views.
Plain Autocomplete widget doesn't use the view at all so I've tried Autocomplete (Tags style) widget as wickwood suggested. I'ts definitely a step forward because the field uses the result of the view but unfortunatelly I can search only in user names (the view contains other attributes such as mother's name)
Any suggestions would be greatly appreciated!

chris matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The latest patch in #18 to entityreference.module does not apply to the latest 7.x-1.x-dev and if still relevant needs a reroll.

Checking patch entityreference.module...
Hunk #1 succeeded at 912 (offset 47 lines).
error: while searching for:
    }
  }
  // Update the value of this element so the field can validate the product IDs.
  form_set_value($element, $value, $form_state);
}

function _entityreference_autocomplete_tags_validate($element, &$form_state, $form) {

error: patch failed: entityreference.module:902
error: entityreference.module: patch does not apply
steinmb’s picture

Status: Needs work » Postponed (maintainer needs more info)

Unable to re-produce this. Anyone that can?

jim22’s picture

`Entity Reference List` View isn't working with my entity reference field. I've tried both autocomplete and autocomplete tags style. Both Select List and Checkboxes do load the view properly, but aren't an option in this use case.

using
Entity reference 7.x-1.5
Views 7.x-3.23