Closed (fixed)
Project:
Inline Entity Form
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Nov 2012 at 20:25 UTC
Updated:
9 Jan 2014 at 13:20 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
rylowry@gmail.com commentedUpdated the title to make it a little more descriptive.
Comment #2
rylowry@gmail.com commentedHere is a patch that attempts to fix this problem. It seems that setting items_count to zero is not a sufficient cleanup. For example, with a field_collections field state also has an array of entities. This patch causes *all* field state for the entity reference's delta to be removed from form state when a row is closed. It was moved to happen each time a row is closed, so cleanup occurs after save and after a cancel. The cleanup after cancel takes care of the situation where you Add Another Item, then cancel out of the form without saving.
Comment #3
bojanz commentedWith your patch applied, I can add a product variation, upload an image, hit save, then go to add another product variation, and in the empty form see the image from the previously saved variation, right? That's the bug this code was written to prevent.
Comment #4
rylowry@gmail.com commentedAh, it looks like I assumed too much. I was thinking that inline_entity_form_close_row_form was also called after the initial save, which was incorrect. I was to wrapped up in testing with existing rows. This patch preserves the cleanup after save, and adds some additional cleanup in inline_entity_form_close_row_form.
Comment #5
rylowry@gmail.com commentedSame patch as above, but hopefully made in the correct manner.
Comment #6
bojanz commentedComment #6.0
bojanz commentedAdded a note about field_collections onto the end.
Comment #7
bojanz commentedSo, two different bugs here:
- the field form state is not properly reset, leading to problems with link, field_collection, etc.
- the cleanup doesn't run on cancellation.
Committed: http://drupalcode.org/project/inline_entity_form.git/commitdiff/0640469?...
- Made the field form state properly reset.
- cleanupFieldFormState should not be a method anymore, moved it to a helper function.
- made it called after a successful entity submit in the process form callback (so that it runs for both IEF widgets).
- made it called when both kinds of forms (add form / edit form) are cancelled.