Only the first referenced paragraph is included.

Created on 21 February 2023, almost 2 years ago
Updated 29 December 2023, 12 months ago

Problem/Motivation

I have a node with multi-valued entity_reference_revisions (paragraphs) field. My node is in create mode and i have 2 paragraph entities as values associated with field machine name field_components. When i add include for field_components, only the last value shows up in the included array.

Steps to reproduce

Add a multi-valued paragraphs field to node. Create a new node with 2 different types of paragraphs selected for the field. View the jsonapi endpoint with include for the field. Notice the attributes value shows multiple but the actual includes only show 1.

Proposed resolution

Refactor line 110 in IncludeResolver.php. Multiple values are present up until this line:
$references[$target_type][$field_item->get($field_item::mainPropertyName())->getValue()] = $in_preview ? $field_item->entity : NULL;
Changing to this works:
$references[$target_type][$field_item->get($field_item::mainPropertyName())->getValue()][] = $in_preview ? $field_item->entity : NULL;

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States apmsooner

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024