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
Comment | File | Size | Author |
---|---|---|---|
#4 | List field update.gif | 2.98 MB | Akhil Babu |
Comments
Comment #2
BenStallings CreditAttribution: BenStallings at Share Good USA commentedComment #3
BenStallings CreditAttribution: BenStallings at Share Good USA commentedComment #4
Akhil BabuI tried to reproduce this issue in Drupal 10.2.2, but was not able to.
Steps followed
Comment #5
Akhil BabuAdding tags as issue is not reproducible.
Comment #7
pixlkat CreditAttribution: pixlkat at Digital Polygon commentedDrupal 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.
In my case, in the function `options_field_storage_config_update_forbid` the `$field_storage` and `$prior_field_storage` arguments do not report the allowed values in the same format. The current values are in a completely different format. This appears to have additional related to form_state --
However the value returned for the prior values returns something completely different. This appears to be the current config storage, without the extra information.
Given what the values are, this code will never work as intended.
Comment #8
pixlkat CreditAttribution: pixlkat at Digital Polygon commentedAfter 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.