Score:0

list_string field data disappears after making edits to node

ng flag

I am maintaining a Drupal 9 site that I inherited. Unfortunately, if I attempt to edit any of the nodes, all the fields of type list_string are empty in the next revision. I did notice that the list_string fields are also showing up empty when I just look at the edit form.

The node data is created by the Webform module and the webform content creator. The issue is not when creating the nodes as that works fine. The issue starts when I am trying to edit the created nodes.

There are no errors in any of the logs. I don't know what to try next.

Will I have to change the field type of all those fields (70 fields total) to retain the data after editing the nodes?

Can I add something in hook_entity_presave() to make sure the values are saved to the next revision?

sonfd avatar
in flag
Do the field values actually align with the options in the field's configuration? That's the first thing I would check.
nschildre avatar
ng flag
There are no options in the field config. It is strange that the original developers picked a list_string field type for fields like First and Last names entered by an applicant in a Webform. Through the Webform content creator only the values are mapped to the list_string field nothing is getting changed in the field config. Can I add something in hook_entity_presave to make sure are saved to the next revision?
sonfd avatar
in flag
I think you better change the field to be a regular text field.
sonfd avatar
in flag
I believe the form tries to match the values with the allowed values, but it can’t. So when you load the form, that’s why you see no values. Then you save the form with no values in the field so any previous values are deleted.
nschildre avatar
ng flag
I've never updated field types with nodes that had already content. Can I follow this page: https://www.drupal.org/docs/drupal-apis/update-api/updating-entities-and-fields-in-drupal-8. And this page? https://www.drupal.org/project/drupal/issues/2843108
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.