TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in in_array() line 196 of core/themes/claro/src/ClaroPreRender.php

Created on 26 December 2023, over 1 year ago
Updated 23 January 2024, over 1 year ago

Problem/Motivation

When creating a new content block type with a chart field the following error appears:
TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in in_array() (line 196 of core/themes/claro/src/ClaroPreRender.php).

Steps to reproduce

1ยบ Activate charts module

2ยบ Create a new content block type

3ยบ Create a new graphic type field

When adding the new graphic field the error appears:

TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in in_array() (line 196 of core/themes/claro/src/ClaroPreRender.php).

Proposed resolution

src/Element/ChartDataCollectorTable.php line 120

Define class attribute like array.

    $table = [
      '#type' => 'table',
      '#tree' => TRUE,
      '#header' => [],
      '#responsive' => FALSE,
      '#attributes' => [
        'class' => 'data-collector-table',
      ],
    ];
    $table = [
      '#type' => 'table',
      '#tree' => TRUE,
      '#header' => [],
      '#responsive' => FALSE,
      '#attributes' => [
        'class' => ['data-collector-table'],
      ],
๐Ÿ› Bug report
Status

Fixed

Version

5.0

Component

Code

Created by

๐Ÿ‡ช๐Ÿ‡ธSpain fjmurillo

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