1

I have two content types A and B. B has an entity reference to A. When creating a view to list all nodes from type A, I want to use some exposed filters. One filter would be to give all nodes from type A that have a reference to a certain node of type B. The exposed filter I get is a textfield that needs a nid. I made it autocomplete (via form_alter), but now the value that gets saved is "node title (nid)".

Anyone having the same problem, and knows how to fix it?

EDIT: I found this patch for entity_reference, but it doesn't seem to work. http://drupal.org/node/1492260

1

The patch I added to the initial question did the trick: http://drupal.org/node/1492260 The only thing you need to know is that you need to enable a checkbox on the fieldsettings of the field on you content type.

0

You can add a validate handler, that pulls out of the nid from the autocompleted text - most use a text like title [nid] or similar. Then set that as the submitted values which View then would use. You need to make sure your validate handler acts first in order for this to work.

  • I'm using this for #element_validate: _entityreference_autocomplete_tags_validate But it's not working. The id doesn't get filled in in the query. – nicolasleroy Aug 1 '12 at 12:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.