Problem/Motivation

Drupal 10.1.2
PHP 8.1.14
If no default value have been set on the field reaction, an error is throw on the add form of the entity.

Steps to reproduce

Add a reaction field on an entity with no default value set (media image in my case)
Add a new media
An error should appear "Warning: Trying to access array offset on value of type null in /var/www/docroot/modules/contrib/votingapi_reaction/src/Plugin/Field/FieldWidget/VotingApiReactionWidget.php on line 113"

Proposed resolution

Add a condition to check if the method $this->fieldDefinition->getDefaultValue($entity); return an empty array

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

vincent signoret created an issue. See original summary.

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

keshavv’s picture

Status: Active » Needs review

Added MR please review.

ahmetburkan’s picture

Status: Needs review » Reviewed & tested by the community

I've tested it and it works as expected. This is ready to be merged!

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

  • elaman committed 7326019b on 8.x-1.x authored by keshavv
    Issue #3383621: Error if no default value have been set to the field...
elaman’s picture

elaman’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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