Drupal 11: Migrate Multivalue Field And Apply Callback To Each Element

Sometimes a simple callback is all that is needed to migrate content, but if you have a multi value field you cant just pass the entire field to the callback plugin as you might be passing an array to a function that expects a string.

For example, to migrate the content of a multi-value field and also convert that field to lowercase (via strtolower) you would do this.

  field_destination:
    - plugin: sub_process
      source: field_source
      process:
        value:
          - plugin: callback
            callable: strtolower
            source: value

The field_destination field now contains the content of field_source, but converted to lowercase.

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
15 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.