Creating multiple entity references of the same type results in duplicates

Created on 3 August 2020, over 4 years ago
Updated 12 February 2024, 9 months ago

When adding multiple entity references of the same type but with different values, the contents of them all are collected and applied to each one.

See entityreference_dragdrop/src/Plugin/Field/FieldWidget/EntityReferenceDragDropWidget.php line 142

$entity_id = $items->getEntity()->id() ?: '0';

In my use case an entity reference field on a content type references paragraphs of multiple types. When adding new paragraphs the entity id will not exist so each list will have an “id” of 0. This is used as a key to set the selected items for the list component. Since both lists will have the same type and id of 0 each list will then “share” the items selected.

🐛 Bug report
Status

Needs review

Version

2.1

Component

Code

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