Entities are not updated during buildEntity() phase

Created on 27 November 2016, almost 8 years ago
Updated 11 May 2023, over 1 year ago

Problem:

Entities edited via IEF do not get updated during the buildEntity() phase of the main entity. This can cause various issues with form workflows that involve a form rebuild.

The issue where I encountered it was two similar issues having the same root cause (this):
- Liveblog module does a preview of posts which reloads the form and adds in the preview, similar as node previews in d7. However, the preview of inline edited entities (media entity tweets) are not updated due to this bug.
- Paragraphs module can show the preview of collapsed paragraphs during editing. The preview of inline edited media entity tweets does not reflect updates - I assume because of the same issue.

Suggested solution

IEF needs to separate entity-building phase and invoke it via the main forms #entity_builder callback. Then the main entity will be updated when needed always.
Finally, the saving of the changes need to be done on the final button. It's a bit hard to detect when this would be the case generically, but as proposed in https://www.drupal.org/node/2830136#comment-11798483 β†’ we could start trying to detect the ::save() method.
However, detecting the ::save method would not be a 100% thing as it would still miss buttions which call save() manually from some other callback. Given this use-case, I think core should be improved to allow the extensions of the entity-save process of an entity form, just as it is already possible with #entity_builders in the build process.

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΉAustria fago Vienna

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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