2

I have a content type Trait, that includes an Entity Reference field Trait Type. A trait type is categorized under a Trait Category. For my Trait content type form I created an Entity Reference View for as follows:

enter image description here

As (if) you can see, I have included a contextual filter that takes Trait Category id values. I've also added a relationship for Trait Type and Trait Category.

The view works as expected, when I enter trait category id values I'm able to filter related trait types.

My difficulty comes when my I want to use this view as my datasource for a Entity Reference field (Trait Types List) I want to add to my Trait content type form.In the field settings field for the Triat Types Entity Reference Field I've done the follow:

enter image description here

Now what I can't understand is:

  1. What View Arguments is supposed to take and do I need to give it any value?
  2. Shouldn't the option "Render Views Filter as a select List" a new select widget to my Trait content type form that would allow me to filter my Trait Type Entity Reference select widget?

Something like this perhaps:

enter image description here

Is my expectation wrong? How can I use this option?

2
  • Maybe you would like this video youtube.com/watch?v=bAPRYVAOAX8#t=32
    – milkovsky
    May 26, 2014 at 14:05
  • Thanks @milkovsky, in the video right at 0:42, it says that the filtering does not work for autocomplete widget. Exactly what I wanted to know.
    – tsega
    May 26, 2014 at 16:03

1 Answer 1

5

1. "Entity selection Views" helps you to deal with options list in the entity reference widget (on node add/edit form). E.g. if you want to reference some nodes that have specific term reference. Entity reference view can help you you.

As I see you want to reference "child" Trait nodes of special category to one "parent" Trait node. (At list your View shows it). In this case you don't have to use contextual filter. You can use ordinary "filter criteria" and set target category value.

2. "Render Views Filter as a select List" - it's not a widget for your content type add/edit form. But it's a widget for exposed filter in views. If you want to use this field as an exposed filter in views by default it's an autocomplete. But this option makes filter as select widget. If you read the "Render Views Filter as a select List" description, you might see that developers advice you not to use this option if you have more that 100 referenced entities. Just imagine a select widget with 100 options and query with WHERE condition. Just mind it.

6
  • Thanks for the answer, #2 is head on! For #1 my understanding was not so much different from what you mentioned. This forces me to ask how do you a filter select widgets using a related (parent) select widget on a node add/edit page? Is the Reference Option Limit module the only way to do it?
    – tsega
    May 22, 2014 at 17:29
  • Module description looks good. But I haven't use it :) Did you try yo implement dependency between your "category" and "trait type" fields with this module?
    – milkovsky
    May 23, 2014 at 8:07
  • Yes it does what it says and it worked for the category - trait type relationship. One problem with that module is that it doesn't work for autocomplete filtering.
    – tsega
    May 24, 2014 at 10:24
  • So your category widget is autocomplete and you want to filter options of entityreference field by the category dynamically, right?
    – milkovsky
    May 24, 2014 at 23:12
  • Trait Category is the parent (a select list) Trait Type is child (an autocomplete). If I make the child Trait Type to have a select list widget I'm able to filter it. However, it does not work for an autocomplete widget.
    – tsega
    May 25, 2014 at 6:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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