AllowedValuesConstraintValidator should only validate "select_or_other" widget

Created on 16 February 2023, over 1 year ago
Updated 16 May 2024, about 1 month ago

Problem/Motivation

Currently AllowedValuesConstraintValidator is checking all the fields with ListItemBase regardless of if it's using the widget type Select or other or not. This can make it challenging for developers to build custom functionality that relies on specific widget plugins. For example workflow is known in #2985361

Steps to reproduce

- Create a computed field extended from FieldItemList
- Attach it to node bundle
- Create a node and exception will be thrown as below:

TypeError: options_allowed_values(): Argument #1 ($definition) must be of type Drupal\Core\Field\FieldStorageDefinitionInterface, null given, called in /data/web/modules/contrib/select_or_other/src/Plugin/Validation/AllowedValuesConstraintValidator.php on line 119 in options_allowed_values() (line 73 of /data/web/core/modules/options/options.module)

Proposed resolution

Update code to look for both type of field with storage and without storage and then check if the fields are using select_or_other widget.

Remaining tasks

Create a fork and traditional patch.

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

RTBC

Version

4.0

Component

Code

Created by

🇦🇺Australia amjad1233 Brisbane

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

Comments & Activities

Production build 0.69.0 2024