4

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?

2 Answers 2

8

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
    Commented May 28, 2019 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
    Commented May 28, 2019 at 6:17
  • 2
    Ah yes, I got the plugin wrong. This should be sub_process instead of get. Thanks a lot.
    – Joost
    Commented May 28, 2019 at 11:00
4

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
3
  • Yep this is working for me too Commented Sep 10, 2020 at 16:36
  • To avoid The value you selected is not a valid choice for the text format, ensure the uid user assigned the entity (e.g. node) has permission to use the format. Commented May 10, 2023 at 11:55
  • The user can be set to blocked (e.g. purpose built migration user) Commented May 10, 2023 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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