Warning when configuration is a multidimensional array

Created on 30 May 2023, over 1 year ago
Updated 3 September 2023, about 1 year ago

Problem/Motivation

When using the Allowed Formats module, it introduces a multidimensional array for its setting which lead to this error when acessing the CT manage field page :

Warning: Array to string conversion in Drupal\field_ui_extras\FieldSummaryBase->processRow() (line 168 of modules/contrib/field_ui_extras/src/FieldSummaryBase.php).
Drupal\field_ui_extras\FieldSummaryBase->processRow(Array) (Line: 121)

This is due to this code :

      if ($item['mode'] == 'inline') {
        $info_markup .= $item['value'];
      }
      elseif ($item['mode'] == 'list') {
        $info_markup .= '<ul><li>';
        $info_markup .= implode('</li><li>', $item['items']);
        $info_markup .= '</li></ul>';
      }

Which will break when in list mode as $item['items'] will be a multidimensional array.

Also the display will show Array instead of a list of the options, cf. this image :

Steps to reproduce

Install the module "allowed format", add a text_long field and visit the manage field page of the CT.

Proposed resolution

Test this value and update code.

Remaining tasks

Patch to be posted.

User interface changes

Also when seeing this special case, there is some CSS that breaks the <ul><li> format so we will introduce a CSS fix for this :
Before:

After:

API changes

None

Data model changes

None

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇫🇷France tostinni

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

Comments & Activities

Production build 0.71.5 2024