Problem/Motivation
when trying to access an EndPoint created with rest_views on a content type which contains an entity reference field we get the following error:
Unable to remove item at non-existing index. in Drupal\Core\TypedData\Plugin\DataType\ItemList
The EntityReferenceExportFormatter->view() function tries removing an item from an empty array.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3472326-unable-remove-item-6.patch | 1.18 KB | vselivanov |
| #2 | rest_views_entityreferenceexportformatter.patch | 693 bytes | alina.basarabeanu |
Issue fork rest_views-3472326
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
alina.basarabeanu commentedComment #3
alina.basarabeanu commentedComment #6
vselivanovThis is definitely an issue.
But patch #2 works only if you need to remove 1 element.
removeItem() function reassign deltas and for the next elements it won’t work.
The solution should be similar to the jsonapi module from Core:
I tested with the multiple field reference to the paragraphs.
I have 3 paragraphs with 2 unpublished:
Unpublished paragraphs are not shown in the $elements after viewElements() and should be removed from the $items
Created MR and added a patch.
Comment #7
phreaknerd commentedWell done.
#6 fixes the issue.
Comment #8
phreaknerd commentedComment #11
nicxvan commentedThanks everyone!
Comment #13
heddnany chance for a new tagged release with this fix?