Fails on Drupal 9.5+

Created on 27 March 2023, over 1 year ago
Updated 9 April 2023, over 1 year ago

Problem/Motivation

Readonly Html Field does not work on newer versions of Drupal.

When you create a node with a Readonly Html Field you'll get a fatal error:
Warning: Array to string conversion in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::castValue() (line 2579 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).

When you edit and save that node, you'll get another fatal error:
InvalidArgumentException: Cannot set a list with a non-array value. in Drupal\Core\TypedData\Plugin\DataType\ItemList->setValue() (line 77 of core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php).

Steps to reproduce

On a Drupal 9.5.7 on PHP 8.1.13 (or something along those lines)

  1. Create a new content type called articletwo
  2. Add the Readonly Html Field to the content type. Allowed number of values: 1
  3. Create a new node of content type articletwo

And you will be rewarded with a typical Drupal error message:
Warning: Array to string conversion in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::castValue() (line 2579...
giving you no clue whatsoever as to where the problem might lie.

Proposed resolution

Sorry. Haven't been able to suss this one out.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇰Denmark Steven Snedker

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

Comments & Activities

Production build 0.71.5 2024