Undefined array key "#view_mode"

Created on 19 March 2024, 3 months ago
Updated 3 April 2024, 2 months ago

Problem/Motivation

Using the SDC Display module to render a paragraph causes the following warning:

Warning: Undefined array key "#view_mode" in Drupal\paragraphs\ParagraphViewBuilder->buildMultiple()
(Line 23 in .../web/modules/contrib/paragraphs/src/ParagraphViewBuilder.php)

Except of the warning everything works fine as expected. (Thank you for this great module :) )

Steps to reproduce

Configure a paragraph type with just the default display mode and assign its fields to a sdc component. Using the paragraph type on any node type leads to the warning.

Proposed resolution

It seems to be caused by paragraphs function that expected the "#view_mode" key in the build array. Adding the key in sdc_display_entity_view_alter solves the issue for me.

Is this the right way of fixing this? Or should paragraphs test for the key?

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Daniel_Rempe Bochum

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

Comments & Activities

Production build 0.69.0 2024