Hi,

I have field collection field "MyProducts". I added 3 field items to the field "field1, field2, field3".

I would like to create a view with field2 and field3 only. When I add field in view, I dont see field collection items in add field page. I only see the main field collection field. In this case, myproducts. How can I create a view with field2 and field3?

Thanks.

Comments

daiwik.addweb’s picture

Please add relationship of "MyProducts" field in your view and then you will able to add its field let say field1, field2, etc.

Thanks

drupalfriend123’s picture

My content type has field1, field2, fieldcollectionfield.
fieldcollectionfield has 3 fields (F1,F2,F3)

In views table page, I added field1, field2.
Added relationship > selected fieldcollectionfield. > selected checkbox require relationship.

Now, how would I just add F1 to the views table?

leistiko_texvet’s picture

The following steps assume you're in the admin page for your view and editing a page or a block. This will likely also work for other view types, but I've only done this successfully with blocks and pages.

  1. Under "Advanced" click on "Add" for "Relationships"
  2. In the Search box that appears, type in the name of your fieldcollection. In your example, you'd type "fieldcollection" Alternately, just find what you're looking for in your list.
  3. Put a checkmark next to the "Content" version of your field collection. Click "Apply (all displays)" or "Apply (this display)" – whichever one fits your needs – to save your selection
  4. On the next page/screen, click "Require This Relationship." You may choose not to do so, but I prefer to and it worked. I recommend not changing "Delta" from "all" - Click "Apply" to save your changes.
  5. Now you're back at the normal admin page for your view. You should see your newly-created relationship under "Relationships." The hard part's done!
  6. Go to "Fields" and click "add"
  7. In the Search box that appears, type in the name of the field you want to display that's in the fieldcollection you just added as a relationship. In your example, you'd type "F1" Alternately, just find what you're looking for in your list. It'll be prefixed by, "Field collection item:"
  8. Put a checkmark next to it and click "Apply" to save your selection.
  9. Configure the field as needed. Click "Apply" to save your changes. Your view should now display the field from your field collection.
  10. Click "Save" to save your view. Frolic with joy.
gcaudle’s picture

Frolicing as we speak. :) Thanks for the step-by-step. 

seagle’s picture

Leistiko - this worked beautifully, accept for any instance that we had multiple entries added to the field collection, a duplicate version of that Node was generated.  Marking the Query setting 'distinct' did not solve this.  Did you run into this issue?

leistiko_texvet’s picture

I have not encountered that issue (yet!). The only thing I can think of off the top of my head is rebuilding registries and clearing caches to see if the situation persists afterward. If any clever "real" solutions come to me, I'll post 'em here.

memcinto’s picture

I, too, am frolicking with joy. Thank you.

dchalmer’s picture

Was just about to give up on using field collections, when I found your post. You are a gentleman and a scholar sir, thank you.

gunie32’s picture

For me the problem resolved after removing the option "show all values in the same line"  and works now link a charm.
 In other words ... Fields -> [your field to your field collection] ->multiple fields  behavior  -> remove the option "show all fields in the same line"

gunie32’s picture

For me the problem resolved after removing the option "show all values in the same line"  and works now link a charm.
 In other words ... Fields -> [your field to your field collection] ->multiple fields  behavior  -> remove the option "show all fields in the same line"