Skip to content

Replacing an Entry Type field with another field while maintaining the content #15814

Closed Answered by brandonkelly
svondervoort asked this question in Q&A
Discussion options

You must be logged in to vote

You can create a new CKEditor field, attach it to the entry type(s) you wish to use it on, and then populate it with values from the original Plain Text field using the resave/entries command:

php craft resave/entries --type myEntryType --set myCkeditorField --to myPlainTextField

Or if the Plain Text field isn’t currently storing HTML, you can wrap its values in a <p> tag:

php craft resave/entries --type myEntryType --set myCkeditorField \
  --to "fn(\$entry) => sprintf('<p>%s</p>', (string)\$entry->myPlainTextField)"

Once you’ve done that and verified the CKEditor fields look right (on all environments), you can remove the Plain Text field from the entry type(s) it’s no longer needed on.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@svondervoort
Comment options

@brandonkelly
Comment options

Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants