HomeDrupalDefine Text Format in Drupal Migrate Field Mappings

Define Text Format in Drupal Migrate Field Mappings

In migrate, defining a text format for a mapped field is fairly straightforward.


$this->addFieldMapping('field_about_us:format')
  ->defaultValue('full_html');

What we’re doing in the example above is mapping the default value “full_html” to the “format” subfield of the “field_about_us” field. This essentially sets the text format to full_html for data migrated into our content type.

More field-mapping specific information can be found in the migrate documentation for field mappings.

But, sometimes it makes more sense to define a default text format for all formatted fields in a migration mapping, and then just override where necessary. To do this, you’ll need to define some options to pass to your migration’s destination class, and include them when defining your destination. Below is an example of how this is done when your destination is Drupal node entities.


$node_options = MigrateDestinationNode::options(LANGUAGE_NONE, 'filtered_html');
$this->destination = new MigrateDestinationNode('business_location', $node_options);

More information on migration destination options can be found in the migrate documentation for destination classes.