Problem/Motivation

I cannot edit a node when the referenced taxonomy term was removed.

Steps to reproduce

  1. Install Drupal and enable the shs module
  2. Create a new vocabulary and add some terms
  3. Create a content type with a entity reference field related with the created vocabulary
  4. Create a new node and fill the entity reference field with any term
  5. Remove the selected term
  6. Open the edit form of the node and click to the save button

Proposed resolution

The hidden text input still contains the target_id and caused the error. I propose to remove the method getSelectedOptions() in favor of using it from the parent \Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsSelectWidget

Issue fork shs-3359851

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

nachosalvador created an issue. See original summary.

nachosalvador’s picture

Assigned: nachosalvador » Unassigned
Status: Active » Needs review
mkindred’s picture

I was suffering from this issue. I applied the patch from MR20, and it seems to have solved the problem for me.

sosig132 changed the visibility of the branch 3359851-the-referenced-entity to hidden.

sosig132 changed the visibility of the branch 3359851-the-referenced-entity to active.

rozzi’s picture

I'm not yet 100% sure my issue is caused by SHS, but I get "This entity (taxonomy_term: X) cannot be referenced." upon the following conditions, though not consistently enough to reliably reproduce. I just know we've run into the issue more than once.

  1. A node is in the process of being edited, and it may or may not have been previewed.
  2. A new term (e.g. within Game developers) gets added to a vocabulary via Taxonomy.
  3. Attempting to save the node results in "This entity (taxonomy_term: X) cannot be referenced" in relation to a separate vocabulary that's not been touched (e.g. Game mode). The only way to save the node is to unselect anything in that vocabulary.

In the described scenario, those and other fields are set to use SHS. I use SHS 3.0.0-beta5 on the latest Drupal 11. It's a production site, but if there are ways I can help pinpoint the issue or definitively attribute it to SHS, let me know what to try.