Allowed values interface gives error when field in use

Created on 24 January 2024, 11 months ago
Updated 29 May 2024, 7 months ago

Problem/Motivation

Drupal 10.2.2 now offers an attractive GUI interface for adding new allowed values to a field and removing ones that are not in use. Except that if you try to submit the form on a field with any existing values, you get an error saying that it cannot have its keys changed.

Steps to reproduce

Create a list field with one or more allowed values. Create or edit an entity with this field, entering a value for the field. Edit the field storage and attempt to add or remove an allowed value. You will see an error saying "Oops, something went wrong. Check your browser's developer console for more details." The developer console and the log will both say,

Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException: A list field 'field_fieldname' with existing data cannot have its keys changed. in options_field_storage_config_update_forbid() (line 116 of core/modules/options/options.module).

Proposed resolution

unknown

Remaining tasks

unknown

🐛 Bug report
Status

Closed: cannot reproduce

Version

11.0 🔥

Component
Field 

Last updated 1 day ago

Created by

🇺🇸United States BenStallings

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue created by @BenStallings
  • 🇮🇳India Akhil Babu Chengannur

    I tried to reproduce this issue in Drupal 10.2.2, but was not able to.
    Steps followed

    • Created a fresh Drupal 10.2.2 site.
    • Added list field (Cardinality 1 & type 'Text') to aricle content type.
    • Added 2 values - 'value-1' and 'value-2'
    • Created an aricle, selected 'value-1' in list field. Published the article.
    • Updated the field configuration of the list field.
      • 'Value 1' is disabed as it is already used in article.
      • Able to add a new value 'Value 3'
      • Able to remove existing value 'Value 2'.
  • 🇮🇳India Akhil Babu Chengannur

    Adding tags as issue is not reproducible.

  • 🇺🇸United States pixlkat

    Drupal 10.2.4. I have a list field where all the values are present in the database. I am trying to simply update the label on one of the allowed values and receive the error. I am not trying to change the keys, only the display text, which should be possible.

  • 🇺🇸United States pixlkat

    After some further investigation, I believe https://www.drupal.org/node/3409364 could be behind what I was seeing. Once I upgraded to the latest version of the Field Permissions module, the behavior I was experiencing above (including the format of allowed values I was seeing in xdebug) is no longer present. I can no longer reproduce this issue.

  • 🇫🇮Finland heikkiy Oulu

    I can confirm that updating Field permissions module to 1.3.0 fixed the issue for us also.

  • 🇺🇸United States majorrobot

    Same here. Had the same error and can confirm updating to Field Permissions 1.3.0 resolved the problem.

    I think it's safe to close this one?

  • Status changed to Closed: cannot reproduce 7 months ago
Production build 0.71.5 2024