There is an issue with the built in MetatagsFieldProcessor
when it creates field data. The existing code does not put the metatag field data within a numeric index, for metatags this is index/delta 0 since the field is never multivalued. This becomes a problem when you click Preview because the ContentTranslationPreviewController
attempts to loop over every field (metatags included) and set the translation for each index/delta field value.
The code path is ContentTranlsationPreviewController::makePreview
calls $translation->get('field_metatags')->offsetGet('basic')
where 'basic' should be the numeric delta/index of the field. This makes its way through the Drupal API until it gets to an InvalidArgumentException
from Drupal\Core\TypedData\Plugin\DataType\ItemList:get
.
In other words, say you have a plain text field named "heading" and a plain text field named "metatags." The plain text field will store as follows,
title
- 0
- value
- #text: field contents
- #translation
- #text: translated field contents
But, the metatags field will store as
metatags
- basic
- title
- #text: field contents
- #translation
- #text: translated field contents
This is all verified on a clean install of core with only tmgmt, tmgmt_content, tmgmt_file, and metatags installed.
I'm including a patch that pushes all the metatag data into an initial index/delta of 0.