0

We have a Drupal 9 site that has a plain text field with existing data that was used for email data. We'd like to convert this field type to email. Is this possible?

6
  • 1
    Does this answer your question? How do I move content from one field to another? Nov 1, 2021 at 16:38
  • 5
    In this case, the easiest way is to create a new field of the email type and then move the data over. If you try to convert the field manually, many bad things will happen; it's much easier to create a new field and move your data to that, then delete the old field. Nov 1, 2021 at 16:39
  • That page's info seems to be for D7 and is for moving data to a new field, not converting an existing field's type. Thank you though. Nov 1, 2021 at 16:42
  • 3
    Generally you cannot convert field types without high risk of something going wrong. So this is the same approach you want to take in Drupal 9-- create a new field, and copy the data over. Nov 1, 2021 at 16:44
  • Patrick is right. You will find it easy to just create a new field and copy data into it. If your concern is about the machine name, you can do it in a 2-steps process: 1) rename text field to something different; 2) create new field using old machine name & copy data into it. On the other side, as they are just configuration, have you tried to do a drush cex, change the field type and then do a drush cim?
    – jbarrio
    Nov 1, 2021 at 17:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.