I have installed a field collection module in my D7 site. There is a multifield(unlimited) field collection with 3 field collection items. I need to delete the field collection programatically.

i use

$field_collection_delete = $node->field_accommodation['und'][$j]['value']  ; 
entity_delete_multiple('field_collection_item', array($field_collection_delete));

$j is a for loop increment value(0,1,2...) to remove field collection

but when i run the code the value in the field collection item deleted(deleted from the db table) but the field collection field i added in the content type is still in the database as none value.

I need to delete that too programmatically.enter image description here

2 Answers 2


You need to unset the field from node first!


You should delete field collections by calling $field_collection->delete(); This handles a few other things for you such as deleting the parent entity.

  • Thanks @Ben, I tried the $field_collection->delete(); but its work same like the entity_delete_multiple(). Only deleting the field collection item from the field collection and not the field collection value from the content type
    – user10644
    Jan 2, 2014 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy