3

I use views-7.x-3.3 and field_collection-7.x-1.x-dev of 2012 Jun 28.

I have a very simple content type (person) with the following fields:

  • name: text
  • surname: text
  • mother language: term reference [en, fr, de]
  • portfolio: field collection of:
    • website language: term reference [en, fr, de]
    • url: link

I can create an exposed views filter on the mother language field just fine. The drop down appears and correctly filters the nodes as expected.

When I try to create a filter on the website language field of the portfolio field collection though, it fails to filter. No results are returned unless the dropdown value is set to "all".

Is it the case that field collection fields cannot participate in views filters? Is there a solution to that?

12
+50

Field collection items can perfectly participate as Views filters. The key is to use Views relationships. You can create a relationship for the portfolio field, and then in the filter specify to use that relationship. That will cause the filter to analyze the field collection's contents, as opposed to the host entity's.

For example, here I established a relationship to an image gallery collection, created a file id filter, and associated the filter with the collection. The fid filter is also exposed:

  • Thanks a lot for taking the time to explain this in detail. It worked. – cherouvim Aug 1 '12 at 8:07
  • no problem @MohammadAlabed, always a pleasure. – amateur barista Jan 23 '15 at 1:59
  • @amateurbarista Views by default creates separate row for each item in the field collection, say I have added 3 set of values to a node. When we add a relationship, the views displays it three times (every row contains all the field collection values) and the exposed filter works well. But when I set the delta to 1 in the view's relationships to display only one row for containing all the values of the field collection, the exposed filter does not work for all the values, instead it works for only the first value of the collection. How do I get over this ? – AkiShankar Feb 22 '16 at 5:50

protected by kiamlaluno Apr 14 '16 at 9:56

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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