Skip to main content
Rollback to Revision 3 - Edit approval overridden by post owner or moderator
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

There is no official solution. String and text fields have different structure (text has an additional format column), you could try to convert it by hand, but you also need to update Drupal's internal information about the field and resulting database schema.

Your easiest option is probably to create a new field and then write a simple script that loads all nodes of that type and assigns the value of the old field to the new. If there are too many nodes to load for a single run, you'll need to split it up or do a batch.

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'yourtype']);
foreach ($nodes as $node) {
  $node->set('newfield',>newfield->value = $node->oldfield->value);>value;
  $node->newfield->format = 'plain_text';
  $node->save();
} 

There is no official solution. String and text fields have different structure (text has an additional format column), you could try to convert it by hand, but you also need to update Drupal's internal information about the field and resulting database schema.

Your easiest option is probably to create a new field and then write a simple script that loads all nodes of that type and assigns the value of the old field to the new. If there are too many nodes to load for a single run, you'll need to split it up or do a batch.

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'yourtype']);
foreach ($nodes as $node) {
  $node->set('newfield', $node->oldfield->value);
  $node->newfield->format = 'plain_text';
  $node->save();
} 

There is no official solution. String and text fields have different structure (text has an additional format column), you could try to convert it by hand, but you also need to update Drupal's internal information about the field and resulting database schema.

Your easiest option is probably to create a new field and then write a simple script that loads all nodes of that type and assigns the value of the old field to the new. If there are too many nodes to load for a single run, you'll need to split it up or do a batch.

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'yourtype']);
foreach ($nodes as $node) {
  $node->newfield->value = $node->oldfield->value;
  $node->newfield->format = 'plain_text';
  $node->save();
} 
Use \Drupal\Core\Entity\FieldableEntityInterface::set function to change field value
Source Link

There is no official solution. String and text fields have different structure (text has an additional format column), you could try to convert it by hand, but you also need to update Drupal's internal information about the field and resulting database schema.

Your easiest option is probably to create a new field and then write a simple script that loads all nodes of that type and assigns the value of the old field to the new. If there are too many nodes to load for a single run, you'll need to split it up or do a batch.

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'yourtype']);
foreach ($nodes as $node) {
  $node->newfield->value =>set('newfield', $node->oldfield->value;>value);
  $node->newfield->format = 'plain_text';
  $node->save();
} 

There is no official solution. String and text fields have different structure (text has an additional format column), you could try to convert it by hand, but you also need to update Drupal's internal information about the field and resulting database schema.

Your easiest option is probably to create a new field and then write a simple script that loads all nodes of that type and assigns the value of the old field to the new. If there are too many nodes to load for a single run, you'll need to split it up or do a batch.

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'yourtype']);
foreach ($nodes as $node) {
  $node->newfield->value = $node->oldfield->value;
  $node->newfield->format = 'plain_text';
  $node->save();
} 

There is no official solution. String and text fields have different structure (text has an additional format column), you could try to convert it by hand, but you also need to update Drupal's internal information about the field and resulting database schema.

Your easiest option is probably to create a new field and then write a simple script that loads all nodes of that type and assigns the value of the old field to the new. If there are too many nodes to load for a single run, you'll need to split it up or do a batch.

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'yourtype']);
foreach ($nodes as $node) {
  $node->set('newfield', $node->oldfield->value);
  $node->newfield->format = 'plain_text';
  $node->save();
} 

There is no official solution. String and text fields have different structure (text has an additional format column), you could try to convert it by hand, but you also need to update Drupal's internal information about the field and resulting database schema.

Your easiest option is probably to create a new field and then write a simple script that loads all nodes of that type and assigns the value of the old field to the new. If there are too many nodes to load for a single run, you'll need to split it up or do a batch.

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'yourtype']);
foreach ($nodes as $node) {
  $node->newfield->value = $node->oldfield->value;
  $node->newfield->format = 'text_plain';'plain_text';
  $node->save();
} 

There is no official solution. String and text fields have different structure (text has an additional format column), you could try to convert it by hand, but you also need to update Drupal's internal information about the field and resulting database schema.

Your easiest option is probably to create a new field and then write a simple script that loads all nodes of that type and assigns the value of the old field to the new. If there are too many nodes to load for a single run, you'll need to split it up or do a batch.

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'yourtype']);
foreach ($nodes as $node) {
  $node->newfield->value = $node->oldfield->value;
  $node->newfield->format = 'text_plain';
  $node->save();
} 

There is no official solution. String and text fields have different structure (text has an additional format column), you could try to convert it by hand, but you also need to update Drupal's internal information about the field and resulting database schema.

Your easiest option is probably to create a new field and then write a simple script that loads all nodes of that type and assigns the value of the old field to the new. If there are too many nodes to load for a single run, you'll need to split it up or do a batch.

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'yourtype']);
foreach ($nodes as $node) {
  $node->newfield->value = $node->oldfield->value;
  $node->newfield->format = 'plain_text';
  $node->save();
} 
use format column
Source Link
4uk4
  • 101.7k
  • 7
  • 173
  • 217
Loading
Source Link
Berdir
  • 83.5k
  • 6
  • 161
  • 207
Loading