1. Create content type "Test" with single field collection field "Test Field" set to unlimited values
2. Add 3 file fields to "Test Field".
3. Create node instance "Test" and upload 3 files into "Test Field" instance.
4. Create simple view that retrieves instances of "Test", set fields to "Test Field" and uncheck "Display all values in the same row" setting under "MULTIPLE FIELD SETTINGS" fieldset. Finally, set Format to "Html list"
5. Preview the results.

All embedded fields are rendered inside single view row.
If I would do the same, say, with file field (image widget) set to multiple values view would output each value on separate row.

I'm aware I could use theming to render field collection items on separate rows but then It would be like single reason to override default templates which satisfies me and it seem to be the wrong reason.
Thanks

Comments

jmuzz’s picture

Status: Active » Closed (works as designed)

The field collection item is a single value on the node, so the behavior is correct. If you want to display the 3 fields in separate rows you can make a field collection item for each of them or you can make a view on field collection items instead of nodes.

n-tuple’s picture

Status: Closed (works as designed) » Active

Thanks for suggestion using field collection view but I still can't get output with several rows for each embedded field.
What I did is:
1. Create field collection item view
2. Set filter to my field collection field
3. Set format to Html list

No matter how I set the fields I always get a single row.

n-tuple’s picture

Moreover, I'm not agree with:

The field collection item is a single value on the node

Field collection is a field in my case configured to have multiple values.
Conceptually it is a field having multiple values.
The fact that each value is also a field is just an implementation detail (conceptually).
It is like having values of different types.
That's how views sees it and kindly offers "MULTIPLE FIELD SETTINGS" fieldset.

jmuzz’s picture

Views sees each field collection item as a single item. It offers you multiple field settings options only when you make a multiple cardinality field collection field. Make it single cardinality and the option won't be there no matter how many fields are in the collection.

Conceptually it is often used to represent a single item. For example you can create a "person" field collection field, and inside it create a "first name" and "last name" field.

Are you sure you can't do what you are trying to do by making a multiple cardinality file field directly on the node? You may not need to use field collections if you just want to have multiple values of a field.

jmuzz’s picture

About your example, if they are separate fields then they will be on the same row. To use the multiple value field settings in views to put the items on separate rows you need a single field that has multiple values.

You mentioned the file field widget as a comparison, but if you create 3 separate file fields on a node you won't be able to use the multiple value field settings in views to put them on separate rows. That will only work if you create a single file field with multiple cardinality.

Field collections does group separate fields, but it's not the same thing as a multiple cardinality field and it won't behave like one.

n-tuple’s picture

I tried different ways to put fields / fields values on separate rows without success and exactly like you say there are 2 options of using multiple value field or fetch node instances or whatever entity is relevant.
I came upon Field Collection module in a hope it handles multi-value fields exactly like "native field" does.

I understand your perspective and I agree that field collection item can be seen as having atomic value which has certain internal structure.
My point is that field collection item has dual nature, first is when you say it is atomic with respect to its value and second nature is what i'm proposing, it should leverage its internal structure and "play" like a "native field".

So your point of view is valid and mine too.
And that's why I'm thinking it could be very usefull to think about it in that way too.

Finally let me elaborate a bit what I'm trying to achieve. I'm building a views slideshow carousel with several slides where each slide contains
a video (html5 video). So I have installed a couple of modules for this to have appropriate field formatters.
The thing is that each video has different dimensions. So if I have single file field instance I will have single widget configuration.
So I need several file field instances each configured differently.
That's where I hoped field collection can help me. I just group all file fields under certain field collection and then configure the view in a way
I described.

Thanks for keeping up with me on this

jmuzz’s picture

If I understand correctly, you have slideshow nodes and they each have a field collection. Inside that field collection are several file fields, but only one of these fields per node will have data because each slide only has one video.

If that's right, then you can just put your fields on the node. Only the ones with data will appear in your view anyway.

Field collections does play like a native field, but there is a difference between multiple value fields and separate fields that can be different types. Field collections or anything else won't be able to make separate fields behave like it's a multiple value field.

n-tuple’s picture

Hi,

...but only one of these fields per node will have data because each slide only has one video...

Sure this setup works but don't you think it is ugly and tricky ?
There are other even uglier ways to achieve what I want.

I'm just asking why in Drupal 7 I can't achieve what I need without requiring dirty tricks.
Again, I think that your module could provide a solution by leveraging its internal structure.

... but there is a difference between multiple value fields and separate fields that can be different types...

How about considering, for now, just the single special case of field collection having multiple fields of the same type ?

jmuzz’s picture

If you want multiple fields of the same type to behave like a multiple cardinality field then your best bet is to make them a multiple cardinality field. If the formatter doesn't work the way you want you can create a custom formatter.

There are good reasons for separate fields and a single multiple cardinality field to have different behavior. For one, if it worked the way you propose then the multiple cardinality options in views wouldn't work on a multiple cardinality field collection field or on the multiple cardinality fields inside the field collection like they're supposed to.

It's not the purpose of field collection to change the way fields work. It just groups separate fields under a single field and that's not the same as a multiple cardinality field. Even the special case you describe would have to be done in a separate module. It could have field collection as a requirement. There are already modules that give more options for displaying field collections and that interact with field collection and views, for example:

https://www.drupal.org/project/field_collection_views

https://www.drupal.org/project/field_collection_table

n-tuple’s picture

Status: Active » Closed (works as designed)
iyyappan.govind’s picture

1) I have a field collection field called "Test" and set to unlimited values.
2) I have two fields inside the "Test" field collection called "Technology" and "Version".
3) Technology is term reference field and version is text field.
4) Now i created the view (not field collection item view) and added the relationship to the "Test" field collection. In that relationship, it asks delta to select the values in the field collection field.
example "select 1" for selecting first value in the field collection.
5) i seleted the 'All' because i need all values. But it doesn't display's all values in the row. It creates the duplicates rows.
Is there anyway to do this without creating field collection item.

Thanks,

samhaldia’s picture

1. Adding Contextual Filters for the field collection and node nid
2. Use All in delta param in Relationships to fetch all records

It fetches multiple values of the collection field row wise