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.
When working with field collections, entity makes them usable, however when dealing with newly attached field collections you are unable to access then via a EntityListWrapper as it is only expecting an id, and the is no way to pass the new entity object.
This makes a small change which allows the field collection module to return any field collections which have not yet been saved as a part of the list so they can be accessed via the EntityWrapper object.
Comment | File | Size | Author |
---|---|---|---|
#5 | entity-1587882-4-5-interdiff.txt | 876 bytes | RoSk0 |
#5 | entity-1587882-5.patch | 4.22 KB | RoSk0 |
| |||
#4 | entity-1587882-4.patch | 3.36 KB | RoSk0 |
| |||
#4 | entity-1587882-4-test-only.patch | 1.04 KB | RoSk0 |
#2 | 1587882.patch | 1.42 KB | gordon |
Comments
Comment #2
gordon CreditAttribution: gordon commentedrecreate the patch against 1.x-dev
Comment #3
fagoThis sounds like a good improvement, so let's do it. Maybe we could just assume we have a list of full objects if the first entry is a object ? Supporting mixed lists doesn't make much sense to me.
However, we should note this possibility at the data-type docs ( see hook_entity_property_info()). Then we should add a little code snippet to the tests making use of the functionality, as this is rather foundational it really shouldn't break.
We cannot rely on entities being of class entity, actually most aren't.
Comment #4
RoSk0Patch is based on @gordon idea because I think it's totally legit use case when first item in the list will be save object and second will be just added, not saved, but we still want to be able to work with it. I wasn't able to figure proper language to update documentation so help here will be appreciated. Patch also includes parent update for unsaved objects and ability to set unsaved object as list item because without this ability this issue in general will be useful only to field collection because it update parent entity directly, without using wrapper, in its FieldCollectionItemEntity::setHostEntity() method.
Comment #5
RoSk0Attempt to update docs.
Comment #6
RoSk0Crosslinking.
Comment #7
GoldThis is looking good to me. Tests are completing successfully.