InvalidArgumentException: "data-region" is an invalid render array key. Value should be an array but got a string. in Drupal\Core\Render\Element::children() (line 98 of core/lib/Drupal/Core/Render/Element.php).

Created on 26 June 2024, 11 months ago

Problem/Motivation

Using Drupal 10.3 I get the following error when trying to translate a block containing a layout paragraph:
InvalidArgumentException: "data-region" is an invalid render array key. Value should be an array but got a string. in Drupal\Core\Render\Element::children() (line 98 of core/lib/Drupal/Core/Render/Element.php).

I grepped for the code and the only place I could find was:

contrib/layout_paragraphs/src/Element/LayoutParagraphsBuilder.php:            'data-region' => $region_name,

Any ideas how that can happen?
Currently I'm unable to create or edit a translation of this block. I deleted the original translation that had the error, but create gives the same error.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: cannot reproduce

Version

2.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

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

Comments & Activities

  • Issue created by @Anybody
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica

    Update: This is super strange!

    This is the full code:

    $build['regions'][$region_name] = [
              '#attributes' => [
                'class' => [
                  'js-lpb-region',
                ],
                'data-region' => $region_name,
                'data-region-uuid' => $entity->uuid() . '-' . $region_name,
                'data-lpb-ui-id' => $entity->uuid() . '-' . $region_name,
              ],
            ];
    

    So I don't think that will affect anything, bein inside #attributes!

  • Status changed to Closed: cannot reproduce 11 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Sorry, this seems to be an issue with https://www.drupal.org/project/layout_section_classes

  • 🇩🇪Germany Anybody Porta Westfalica

    Final update: This was a mistake in a custom layout twig file.
    We had interated through a render array with #attributes and the expected sub-render array and rendered them individually. That caused the issue.

Production build 0.71.5 2024