Hi all,

In my content type A I have a Entity Reference field pointing to content type B, with an autocomplete widget to use the References Dialog module.

It's all ok: dialog "popup" appears showing my specific View. This View exposes some taxonomy filters to allow filtering results. Ok: filters, view and Dialog do their job and the autocomplete text field is correctly filled with the node of my choice.

The problem is that the autocomplete functionality of this text field is active and so, if a user starts typing some words, a list of nodes suggestion appear, regardless of filter restriction I've setted up in my views, nullifying all this stuff and the scope of this module.

EXAMPLE:

  • Content type A -> Content type B
  • Content type B is categorized with a taxonomy vocabulary (e.g COLORS: red, yellow, blue, green, gray, white, black)
  • My View appearing in the References Dialog exposes that taxonomy as an exposed filter, with a restricted range of terms of the vocabulary (e.g. only red, yellow and blue)
  • Using this filters only nodes of type B tagged with red, yellow and blue can be listed as results (that's what I want)
  • I choose a node tagged with RED from my results
  • The dialog disappear and the autocomplete text filed is correctly filled with the resulting node (all ok)
  • PROBLEM: if I start to type some text in the autocomplete field, ALL nodes of type B can appear as suggestions, also if they are tagged with "proibited" colors (green, gray, white, black), nullifying my views filters.

Is there a way to disabling the autocomplete feature? Or any other workaround?

Thank you very much

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MXT’s picture

Priority: Normal » Major

A new feature has just been commited in the EntityReference module: "Add views support for providing a list of entities or bundles (views filtering, relationships, etc)" (see: http://drupal.org/node/1253776).

Can we hope in any sort of integration to reach the feature/issue described here?

Thank you very much.

MXT’s picture

Priority: Major » Critical

I'm quite puzzled by the fact that nobody has given the deserved attention to this problem.

I'll change this bug as critical because, in fact, this issue makes this module completely unusable. What's the need to do a view with some filters set, when they can be simply bypassed through the autocomplete after closing the dialog?

Thanks for putting more attention on this problem.

fabsor’s picture

Title: Disable autocomplete text field functionality to NOT vanify filters already setted up in views » Integrate better with autocomplete options from entity reference
Category: bug » feature
Priority: Critical » Normal

References dialog doesn't change the configuration for the formatter it is attached to, it only adds a link to a view where you can select things. Entity reference has it's own settings for limiting content which should be used for this.

You can easily use the same view with the same filter by creating two displays, one for references dialog and one for entity reference. This should do the trick.

Integrating with this functionality from entityreference will be hard to do cleanly, the easiest solution is to simply use the same view for both entityreference and views.

This is definitely not critical, and not a bug either. A critical bug is a bug that makes your site unusable, for instance a PHP fatal error. This is definetly not the case here.

MXT’s picture

FileSize
181.99 KB

Thank you Fabsor for your answer.

What you suggest is the first thing I tried.

The point is that there is a problem: the "add dialog" feature now allow to create ALL kind of node types, regardless of the filtered entities provided by Views.

Please see the image in attachment that shows the issue.

Thank you very much for considering this issue.

fabsor’s picture

Title: Integrate better with autocomplete options from entity reference » All bundles are shown when using views to filter allowed content with entityreference
Category: feature » bug

Ahh, now I see the problem. I completely misunderstood it before, sorry.

We need to check if entity reference uses views and get the result from there in that case. This should be possible to do.

MXT’s picture

Priority: Normal » Major

I think this bug as to be turned to major because de facto makes this module unusable for not skilled users (e.g. our clients with editor role remain confused with plenty of erroneous options to add content types).

Do you have any plans to resolve it?

Thank you very much

mortician’s picture

Same problem. Any update on this?

jygastaud’s picture

Here is a small patch for entityreference views filters support.

The patch supports only Node entity type.

MXT’s picture

Yes patch in #8 works very well for me: thank you very much!!!

MXT’s picture

Status: Needs review » Reviewed & tested by the community

Can this be committed please?

Thank you very much

rogical’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

liquidcms’s picture

Status: Closed (fixed) » Active

sorry to re-open but i think my issue is close enough to simply add to this issue.

to start with.. i am using userref (this patch only supports noderef; so possibly that is the only issue here remaining).

my initial issue was that entityreference autocomplete does not provide realname support (#1299156: Support for realname). i then found i could use a view for the entityref source to add realname support and it worked great; except that as soon as i switch entity selection mode from Simple to Views; then i lose support for ref dialog

if this isn't close enough to be considered part of this original issue; let me know and i will raise a new issue.

liquidcms’s picture

oh yes.. and gives this error:

Warning: array_keys() expects parameter 1 to be array, null given in references_dialog_entityreference_add_link() (line 250 of /home/admin/public_html/calpoly/sites/all/modules/Fields/references_dialog/references_dialog.dialog_widgets.inc).

liquidcms’s picture

FileSize
712 bytes

simple fix to make this work for users as well.

liquidcms’s picture

Status: Active » Needs review