Entity reference field values from the referencing entity are overwriting values of the referenced entity in the edit modal

Created on 28 August 2017, over 7 years ago
Updated 12 March 2024, about 1 year ago

2 types of content, A and B.
A refers to B via a entity reference field, with the Entity Browser widget. It's configured to show the edit and remove buttons.
Both A and B have another entity references field, to files.

When I'm in the edit form of A and press the Edit button on B, a modal is opened with the edit form of B. However, not the files of B show up in the modal, but the files of A.

The cause of this is EntityReferenceBrowserWidget::getEntitiesByTargetId() using the unfiltered $form_state->getUserInput(), which contains the values of A's edit form, which are submitted when opening the modal via AJAX. The code in question was added in #2764889: Entity Browser widget loses selected images in inline entity form . A code comment already mentions that this needs to be refactored, "// TODO Figure out how to avoid using raw user input." and there seems to be a ticket for that as well, #2825890: Refactor and clean EntityReferenceBrowserWidget::formElementEntities() , but I was not able to find a bug report yet about the wrong field values being used in the modal.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Widget plugins

Created by

🇧🇪Belgium Cyberwolf

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

Merge Requests

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