I'm migrating recipes from an api into Drupal 8. I have a field "field_recipe_ingredients" Text(formatted) Allowed number of values: unlimited

In the process plugins when I have the following value:

field_recipe_ingredients: ingredients

it works fine

When I put the following:

  'field_recipe_ingredients/value': ingredients
  'field_recipe_ingredients/format':
    plugin: default_value
    default_value: 'full_html'

it fails with the following error:

InvalidArgumentException: Placeholders must have a trailing [] if they are to be expanded with an array of values. in [error]
Drupal\Core\Database\Connection->expandArguments() (line 719 of
/Users/selwyn.polit/Sites/d8_test1/drupal/core/lib/Drupal/Core/Database/Connection.php).
exception 'PDOException' with message 'SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'sourceid1' at[error]
row 1' in /Users/selwyn.polit/Sites/d8_test1/drupal/core/lib/Drupal/Core/Database/Statement.php:64

Ingredients returns a simple array of strings.

Any thoughts welcome!

Comments

selwynpolit created an issue. See original summary.

mikeryan’s picture

My guess here is that there's a mismatch between the /value, which is being populated with an array, and /format, which is being populated with a scalar - when trying to assign a format to each value, it's trying to dereference an array that isn't an array. It would be nice if the situation was interpreted as "apply this scalar value to every member of the array", but that's not how it's implemented, not sure how hard that would be.

A possible workaround may be for your source plugin to populate a 'format' array which a 'full_html' value for each ingredient, and map 'format' to 'field_recipe_ingredients/format'.

quietone’s picture

Version: 8.0.1 » 8.1.x-dev
rodrigoaguilera’s picture

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.

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.

mikeryan’s picture

Status: Active » Fixed

Actually, having run into these situations in recent months, the iterator plugin addresses this nicely:

  field_recipe_ingredients:
    plugin: iterator
    source: ingredients
    process:
      value: value
      format:
        plugin: default_value
        default_value: full_html

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.