Problem/Motivation

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

Steps to reproduce

Create field options list and check on default value

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lazzyvn created an issue. See original summary.

sourav_paul’s picture

Assigned: Unassigned » sourav_paul
sourav_paul’s picture

I've tested it on drupal 10.3 with module version 4.1 this is working as expected even with default value of select list.

Attaching ss...

Please provide proper issue reproducing steps..

ikphilip made their first commit to this issue’s fork.

ikphilip’s picture

I found this error except using module select_or_other 4.2.0 and Drupal 10.4.1.

Steps to Reproduce

  1. Install Drupal 10.4.1
  2. Install select_or_other 4.2.0 (or dev-4.x)
  3. Enable select_or_other
  4. Create a new field (configurable entity like Node or Content Block).
  5. Selection List field, List (text)
  6. Create at lest 2 allowed values.
  7. Check "Set Default Value" and choose one of the created allowed values.
  8. Save settings. Error should occur.

Proposed Resolution

Adjust the code in AllowedValuesConstraintValidator::validate() to more closely match the way it's done in Core.

See Merge Request.

ikphilip’s picture

Version: 4.1.0 » 4.2.0
Status: Active » Needs review
b-prod’s picture

Status: Needs review » Reviewed & tested by the community

@ikphilip I tried the patch and it solves the issue, allowing to save the field successfully.

spadxiii’s picture

quick note: the fail in the pipeline is a risky test. Otherwise it passes all tests.

Patch applies cleanly to 4.2.0 and seems to work just fine.

ivnish’s picture

Assigned: sourav_paul » Unassigned
Status: Reviewed & tested by the community » Needs work

Needs to check why one test failed

ikphilip’s picture

Status: Needs work » Reviewed & tested by the community

ListWidgetTest::massageFormValuesAddsNewValuesToAllowedValues had no assertions. This is resolved in the MR.

  • ivnish committed 28357bac on 4.x authored by ikphilip
    [#3481566] feat: Fatal error with default value
    
    By: lazzyvn
    By:...
ivnish’s picture

Version: 4.2.0 » 4.x-dev
Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.