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

7

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, 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
    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
    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 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. May 10 at 11:55
  • The user can be set to blocked (e.g. purpose built migration user) May 10 at 12:55

Your Answer

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

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