Error: Cannot use object of type Drupal\Core\StringTranslation\TranslatableMarkup as array

Created on 26 May 2025, 5 days ago

Problem/Motivation

I get the following error when I try to add default values to a multi-value formatted text field:

Error: Cannot use object of type Drupal\Core\StringTranslation\TranslatableMarkup as array in Drupal\text\Plugin\Field\FieldType\TextFieldItemList->defaultValuesFormValidate() (line 24 of /app/web/core/modules/text/src/Plugin/Field/FieldType/TextFieldItemList.php).

The "add_more" button is handled as a submitted value and that is causing an error in the allowed_formats check.

Steps to reproduce

  1. Add a formatted text field to a node type
  2. Select "Text (formatted)" as the field type
  3. Make sure at least one format is selected in the "Allowed formats" list
  4. Click the "Add item" button to add another default value

Proposed resolution

Check if the value "add_more" is set and remove it if so.

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

field system

Created by

🇳🇱Netherlands Ewout Goosmann

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

Comments & Activities

Production build 0.71.5 2024