Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#5 | sort_deltas-2316411-5.patch | 703 bytes | Den Tweed |
#3 | sort_deltas-2316411-3.patch | 862 bytes | Den Tweed |
#1 | sort_deltas-2316411-1.patch | 585 bytes | plopesc |
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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: Den Tweed commentedComment #6
Den Tweed CreditAttribution: Den Tweed commentedNew patch against latest release