Problem/Motivation
When removing a field collection item via Delete link on entity view, method deleteHostEntityReference() unsets the delta value, but does not sorted again the deltas. IE: Having deltas [0, 1, 2, 3, 4, 5] and removing 1 and 3 via Delete link on entity view, results on deltas [0, 2 ,4 ,5]. Doing the same task via entity form, results on [0, 1, 2, 3].
Proposed resolution
To keep consistency and avoid messed delta values, delta values could be sorted in deleteHostEntityReference() after removal.
Remaining tasks
Patch
Review
User interface changes
None
API changes
None
Comments
Comment #1
plopescAttaching simple patch that sorts deltas before saving host entity after removal.
Regards.
Comment #2
plopescBump.
This is a simple patch that improves module's consistency
Comment #3
den tweed commentedThis was for me a much needed patch as I needed the delta's of the field collection items in a view listing to make a #item/total items field. As the field collection entity code has now been moved to a separate file I've updated the patch to work with the most recent dev. Works as a charm!
Comment #4
chris matthews commentedThe patch in #3 does not apply to the latest 7.x-1.x-dev and may be too old to reroll, but I went ahead and tagged the issue accordingly.
Comment #5
den tweed commentedComment #6
den tweed commentedNew patch against latest release