Using class attribute throws type error

Created on 14 October 2025, 23 days ago
Updated 23 October 2025, 14 days ago

Problem/Motivation

Related to attributes support introduced in Use attributes from link field ? Active .

When using the class attribute, following error is thrown:

TypeError: html_entity_decode(): Argument #1 ($string) must be of type string, array given w html_entity_decode() (linia 398 w /var/www/drupal/web/core/lib/Drupal/Component/Utility/Html.php).

#0 /var/www/drupal/web/core/lib/Drupal/Component/Utility/Html.php(398): html_entity_decode()
#1 /var/www/drupal/web/modules/contrib/linked_field/src/LinkedFieldManager.php(267): Drupal\Component\Utility\Html::decodeEntities()
...

In code added in https://git.drupalcode.org/project/linked_field/-/commit/3ff6a32072c7742b26c4bc43300df778baa0610d class attributes are stringified before decoding HTML entities, but this step was added only in the code path for img/picture HTML elements. When the class attribute is used on another element the error is thrown.

Proposed resolution

Stringify class attribute before further processing also for html elements other than img/picture.

🐛 Bug report
Status

RTBC

Version

1.7

Component

Code

Created by

🇵🇱Poland wotnak

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024