When using the embedded widget removed field collections get never deleted.

We probably should implement hook_field_update() and check for removed field collections and delete them once removed.

Comments

fago’s picture

Status: Active » Fixed

I've committed a fix for that + an update routine that takes care of deleting orphaned field collection items. Please test and report whether the update went fine for you.

Niremizov’s picture

I belive this issue somehow related with #1781190: Field Collection saved on presave.

cornelyus’s picture

Hello all

I think I have the same problem..

I have the latest dev from fago, and what happens to me is this.

I fill one field collection

then Add Another Item

If I click remove on this last item, it doesn't disappear.. If I click a second time what it does is, it saves my node form.

What I saw on the module was that the first time I click "Remove" the button comes with info that is of type submit, and name Remove.
The second time this changes and it says it's of type submit, and name Save.

I am talking about this piece of code :

// Get the information on what we're removing.
$button = $form_state['triggering_element'];

Thanks for your time..

Status: Fixed » Closed (fixed)

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

jamsilver’s picture

Glad this has been finally fixed! Marked #1186826: Delete orphaned field_collection_item entities when they are (programatically) removed from the host entity as a duplicate.

Just a small note: This solution doesn't work if the host entity of the field collection is of an entity type declared (by a custom module) without the use of entity api. Of course in that tiny tiny case, the best answer would probably be to rewrite your module to use entity api!

This is because of the code's reliance on the $entity->original property - something placed there by entity api.

Nick Robillard’s picture

fago: what's the commit this happened on?

EDIT: Nevermind - it's painfully obvious when I look at the commits. :)

nithinkolekar’s picture

Issue summary: View changes

is it committed in 7.x-1.0-beta7 ?
don't find patch code(https://drupal.org/comment/5637234#comment-5637234) in latest version.