2

I'm figuring out how migrating works. When trying to migrate one of my nodes from a Drupal 7 site to Drupal 8 site I can't figure out how to set the Text Format of a field. I found this solution below, when looking for an answer, but this doesn't work.

field_name:
      plugin: get
      source: field_name
      process:
        value: value
        format:
          plugin: default_value
          default_value: "basic_html"

I also tried something like

field_name:
          plugin: get
          source: field_name
field_name/format:
          plugin: default_value
          default_value: "basic_html"

Or

field_name/value:
          plugin: get
          source: field_name
field_name/format:
          plugin: default_value
          default_value: "basic_html"

But non of these work. What am I doing wrong?

6

Have you tried removing the quotes?

field_reference:
-
  plugin: sub_process
  source: field_reference
  process:
    value: value
    format:
      plugin: default_value
      default_value: basic_html
3
  • Hi, yes i tried with and without quotes. But the result is the same. The text format in the created node says: select instead of Basic HTML. – Joost May 28 '19 at 6:14
  • What about using sub process like above? I'm still just getting to grips with migrations but this worked for me. – dibs May 28 '19 at 6:17
  • 2
    Ah yes, I got the plugin wrong. This should be sub_process instead of get. Thanks a lot. – Joost May 28 '19 at 11:00
2

Although it is more elegant to use a sub_process as @dibs proposed, you can also use a get process plugin

field_name/value:
  - plugin: get
    source: field_name/0/value
field_name/format:
  - plugin: default_value
    default_value: basic_html
1
  • Yep this is working for me too – ben.hamelin Sep 10 '20 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.