Using field's config default value overrides first selected option

Created on 1 April 2024, about 1 year ago

Problem/Motivation

When given an entity reference with a cardinality greater than one and setting the default value via the field's config; the first value submitted in the entity reference is overriden to the default value.

Steps to reproduce

Given you have a vocab Tag with the following terms:

  • Foo
    • Bar 1
    • Bar 2
    • Bar 3

And a content type Article with an entity reference to Tag. Use the SHS field widget.

  • Via the field's config, set the default value to Foo and the cardinality to greater than 1.
  • On the content type's create form, add two values for Tag, Bar 1 and Bar 2
  • Click save
  • confirm that Tags value is Foo and Bar 2
  • Note, on update the SHS field widget works

Proposed resolution

The issue appears to be related to having a default value set and the widget's javascript not correctly interpreting or handling that causing the first item to always revert back to the default value set for the field on the first save. If I remove the default, it works.

Drupal version: 10.2.3
SHS version: 2.0.0-dev

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States robpowell Boston

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

Comments & Activities

Production build 0.71.5 2024