When I programmatically create nodes I need to copy a field collection from one entity to another. Instead of copying I just assign the field collection ID to the new entity. This has the big advantage in my usecase that if the field collection from one entity is changed it automatically works for all other entities (which are sharing the same field collection) too. Is this in scope of the module or shouldn't I do this - eg. for cache rebuild reasons. The function FieldCollectionItemEntity::fetchHostDetails() seems to be able to return just one host entity. So I guess it's not good to use field collections this way.

Would be nice to get a reccommendation. Is it save to reuse/shate the field collection item on multiple entities or not. Should I better clone the entity (like in #1304214: Doesn't clone properly) and implement my custom mechanism for changing multiple field collections by editing just one?

Comments

ndewhurst’s picture

I had the same question. For my use case, the client wants to be able to reuse certain sets of data that are stored in field collections. It is not so important that the data be centrally managed as that they avoid repetitive data entry, so I may just extend the field collection widget to allow content admins to populate a FC with data from an existing one, to use as a starting point, but still save it as a new FC entity.

jmuzz’s picture

Issue summary: View changes
Status: Active » Fixed

For this use case it would be better to use an entity reference field. A field collection should only have a single host and it's the only scenario that can be supported.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.