When attempting to add field collection instances on multiple entities via VBO's "modify entity values" operation, a single instance of the field collection is created and referenced by all the selected entities.

Any subsequent editing of a field in that collection instance on any of those entities (by any method) also edits that field on all those entities. Ack.

I'm calling this a bug, since field collection instances are supposed to be unique to their parent entity instance, right?

CommentFileSizeAuthor
#12 RTFM.png43.84 KBstevesmename

Comments

johnpitcairn’s picture

So, VBO allows you to set values for fields on an entity. It displays the field forms for the entity, meaning if the field collection is embedded (and possibly if not, I haven't checked), you'll see all the fields in the field collection form. But VBO is only concerned with the field collection instance in the parent entity, not the fields in the collection, so it can either:

A: replace the field collection instance(s) in the selected parent entities with the new, single (shared) field collection instance you have now defined in the VBO interface, or

B: add the new (shared) field collection instance you have defined in the VBO interface to all the selected parent entities.

Neither of these are desirable options. I doubt there is likely to be any non-confusing way to handle VBO operations on multiple entities containing existing field collections (??). If not:

1: field_collection should refuse to be available for "modify entity values", if this is possible, or

2: VBO should detect field_collections as a special case, and not add those to "modify entity values" (in which case this gets bumped to the VBO issue queue).

Anonymous’s picture

I have noticed this issue too.

Yuri’s picture

Issue summary: View changes

Any progress here?

Yuri’s picture

Priority: Normal » Major
paulihuhtiniemi’s picture

I'm also interested on this! If any of you have ideas on some custom sulotion on how to alter this functionality to get it save new field collection instance for all each entity, I'm all ears :)

paulihuhtiniemi’s picture

I tested latest DEV version of field_collection and it doesn't seem to work at all with VBO (3.2). It throws exception "The host entity cannot be changed.", introduced in #2013811-10: field_collection_field_update() saves old host entity and overwrites changes

basillic’s picture

Same issue too...

jiv_e’s picture

I had the same error as @paulihuhtiniemi. I'm not sure if this issue is the correct place to handle this. I may have to start a new one, maybe on the VBO issue queue.

I looked into this and found an ad hoc solution. The problem lies in the fact that PHP5 assigns objects as reference. Views_bulk_operations code has some references to entity objects when they should be clones. I'm trying to find a clean general solution to fix this. I'll keep you informed.

jmuzz’s picture

Priority: Major » Normal
adrien.felipe’s picture

I believe this to be related with: #2658882: "the host entity cannot be changed" error with VBO

I'm now looking for a way to "Add new Field collection, instead of overwriting the existing values.", like with taxonomy.

abelaguado’s picture

I had the same problem and solved it by changing the 'Number of entities to load at once' --> set to 1, in BULK OPERATION SETTINGS

I'm using 7.x-1.0-beta8 ...

stevesmename’s picture

StatusFileSize
new43.84 KB

#11 fixed my problem. The other half of the problem was related to #10, you want the VBO to be on the parent entity of the field collection (not the field collection entity itself). For me I need to bulk modify the node entity to be able to modify/create a field collection entity. And the "(if all else fails) set this to 1" is likely because of issues in coding of not able loop into entity fields and bulk update more than 1 at a time.