When migrating data into drupal into a field with a text format, if you specify it like this:
'field_recipe_nutritional_info': basic_nutrition
and follow up the text format like this:

  'field_recipe_nutritional_info/format':
    plugin: default_value
    default_value: 'full_html'

The field_recipe_nutritional_info data will always be blank and the format will not be set correctly.

If instead you specify this (note /value) it works fine. Both the value and the format are set correctly.

  'field_recipe_nutritional_info/value':
  'field_recipe_nutritional_info/format':
    plugin: default_value
    default_value: 'full_html'

In processRow() it calls $row->setDestinationProperty($destination, $value);
which overwrites the field value. whoops!

For reference, here is the rest of the project including the yaml file in question

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

selwynpolit created an issue. See original summary.

selwynpolit’s picture

Issue summary: View changes
mikeryan’s picture

Yes, it would seem that the unqualified form causes the entire field array to be written by that mapping. One might hope that it would somehow "know" what the primary value is and only write that specific value, but the Row class where this is happening knows nothing of field structures. We may need to simply document that when migrating multiple subvalues of a field, the primary value's subfield must be explicitly mapped.

quietone’s picture

I'm all for improving the documentation and this looks straightforward. Though, I'd prefer to have agreement before I change it. (Don't want to get it wrong and confuse folks.)

So, I reckon the information can go on Migrate process right after "Handling multiple values".

-- start example documentation --
Handling multiple subvalues of a field

The primary value of a field and all the subfields must be explicitly mapped. The following example uses the default_value plugin to map the format subfield.

  'field_name/value':
  'field_name/format':
    plugin: default_value
    default_value: 'full_html'

-- end example documentation --

quietone’s picture

Version: 8.0.1 » 8.1.x-dev

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mikeryan’s picture

Title: when specifying text format you must specify value » Document that when specifying text format you must specify value
Category: Bug report » Task
Issue tags: +Documentation

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

prash_98’s picture

Status: Active » Needs review
FileSize
518 bytes
518 bytes

Have added the comment for the same. Please review it.

prash_98’s picture

Sorry attached the same patch file twice by mistake.

jofitz’s picture

Status: Needs review » Needs work

Firstly thanks for your contribution, @prash_98 - welcome to Drupal!

I'm afraid I doubt this is where @mikeryan and @quietone intended for the documentation to appear. Out of interest, why did you choose this file?

But before I'd even noticed that, I had a few points of feedback:

  1. There is a typo and/or a repeated word (depending on which patch you read!):
    + * Along with thw the text also specify the text value.
    + * Along with the the text also specify the text value.
  2. Comments do not require a new line until they reach 80 characters.
  3. Comments should (noramlly) begin with a capital letter (you did this - great) and end with a full stop / period .
Munavijayalakshmi’s picture

Assigned: Unassigned » Munavijayalakshmi
prash_98’s picture

Thanks and would surely keep this in mind for the issues ahead.

chiranjeeb2410’s picture

@prash_98

Make the changes accordingly in the correct file and then upload the patch.

Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned
jofitz’s picture

Status: Needs work » Needs review
  1. Removed @file.
  2. Corrected comment.
jofitz’s picture

Helps if I add the files too!

heddn’s picture

Assigned: Unassigned » heddn

Assigning to myself for review.

heddn’s picture

Assigned: heddn » Unassigned
Status: Needs review » Needs work

The place for this documentation seems strange, as noted in #11. Let's move this either into the yml file for formats.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jofitz’s picture

Status: Needs work » Needs review

Added the documentation suggested by @quietone in #4:
https://www.drupal.org/docs/8/api/migrate-api/migrate-process-plugins/mi...

heddn’s picture

Status: Needs review » Needs work

So, does #21 fix this? Or do we need to add a patch to change some doc block?

quietone’s picture

I've gone back and forth on this for the last wee while. Finally decided that it is a bit of a gotcha so it is better to add some documentation to processRow() about the consequences of $row->setDestinationProperty($destination, $value);

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

heddn’s picture

While can figure out the "main" propery value (see FieldItemInterface::mainPropertyName), that main property isn't used for base fields. It seems too much work to figure out the difference. This seems like a docs only fix. Probably could live on the d.o. documentation page about working with process plugins and how nested values function.

Tagging.

masipila’s picture

Status: Needs work » Closed (outdated)

Based on #25, this is handbook documentation fix only.

I checked our handbook and it covers this info, see https://www.drupal.org/docs/8/api/migrate-api/migrate-process-plugins/mi...

Closing this as outdated. If someone feels that something else should be done under this issue, please re-open and specify the proposed actionable next steps.

Cheers,
Markus