Problem/Motivation
When clicking "Save" in Mercury Editor, if a Paragraph type has a field which references another Paragraph type, the .theme preprocess function is not able to access the the Target IDs contained within the field. This causes the Mercury editor preview to fail to render the Paragraph type content.
Steps to reproduce
1.
Create a Paragraph type, "testing".
In this PT, create a field, ex: "field_paragraphs".
Have "field_paragraphs" reference another Paragraph Type:
- Entity reference revisions
- Reference type: Paragraph
2.
In your .theme file, create a paragraph preprocess function. Within this function, attempt to get the target IDs of the "field_paragraphs" field:
function my_theme_preprocess_paragraph(&$variables) {
$paragraph = $variables['paragraph'];
$paragraph_type = $paragraph->bundle();
$field_paragraphs = $paragraph->get('field_paragraphs')->getValue();
foreach ($field_paragraphs as $key=>$field_paragraph) {
$field_paragraph_data[$key] = $field_paragraph['target_id'];
}
$variables['field_paragraph_data'] = implode(" ", $field_paragraph_data);
Have your template reference the data, ex: {{ field_paragraph_data }}
3.
Using Mercury Editor, create a new "testing" paragraph type.
Fill its 'field_paragraphs' sub-fields with several values.
Upon saving, the Mercury Editor preview page will not display the values.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes