Include Entity Object When Updating The Existing Entity

Created on 8 March 2017, over 8 years ago
Updated 30 March 2023, over 2 years ago

This is related to how we validate the child entities inside the parent's entity constraint validator, we can use the following code to get the value of child entities.
$child_entities = $items->get('child_entity_field')->getValue();

When we adding new child entity, the new entity object can be accessed from $child_entities[0]['entity']. Below this is the structure of $child_entities when we print_r it.

Array
(
    [0] => Array
        (
            [weight] => 1
            [form] => 
            [needs_save] => 1
            [target_id] => 
            [entity] => ---> The entity object here.
        )
    [1] => Array
        (
            [weight] => 2
            [form] => 
            [needs_save] => 1
            [target_id] => 
            [entity] => ---> The entity object here.
        )
)

But, when we update the existing child entity, the entity object is not included anymore. When we print_r it, we get the following structure.

Array
(
    [0] => Array
        (
            [weight] => 0
            [form] => 
            [needs_save] => 
            [target_id] => 8
        )

    [1] => Array
        (
            [weight] => 1
            [form] => 
            [needs_save] => 
            [target_id] => 9
        )
)

What about including the updated child entity structure there just like when we add the new one? I think it will be usefull because we can use that in constraint validator in the parent entity.

Feature request
Status

Postponed: needs info

Component

Code

Created by

🇮🇩Indonesia bogeyman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024