Exception when only 1 option is available

Created on 29 October 2025, 22 days ago

Problem/Motivation

There is an exception thrown when using the multiselect widget on unlimited cardinality fields that only have 1 option.

Steps to reproduce

1. drush si standard -y
2. Log in as admin
3. Add a single term to /admin/structure/taxonomy/manage/tags/overview
4. Enable the multiselect module
5. Go to /admin/structure/types/manage/article/form-display and make field_tags use the Multiselect widget
6. Go to /node/add/article
7. Fill in the title and pick the term you created. Try to save the node.

Notice

The website encountered an unexpected error. Try again later.

TypeError: Drupal\Core\Field\WidgetBase::massageFormValues(): Argument #1 ($values) must be of type array, string given, called in /var/www/html/docroot/core/lib/Drupal/Core/Field/WidgetBase.php on line 516 in Drupal\Core\Field\WidgetBase->massageFormValues() (line 662 of core/lib/Drupal/Core/Field/WidgetBase.php).

Drupal\Core\Field\WidgetBase->extractFormValues() (Line: 256)
Drupal\Core\Entity\Entity\EntityFormDisplay->extractFormValues() (Line: 334)

Proposed resolution

Fix the widget to avoid this.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇸🇮Slovenia alecsmrekar

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