I am using the Paragraph module in and I need to programmatically create paragraph entities and attach them to nodes.
Using the following code in a for-loop:
$paragraph = new ParagraphsItemEntity(array('field_name' => 'field_page_body', 'bundle' => 'text')); $paragraph->is_new = TRUE; $paragraph->setHostEntity('node', $node); $paragraph->save(TRUE);
The paragraph entities are created and attached to the target node but the data is NULL
for all 3 entries as the image below shows:
A properly working set of Paragraph entities attached to a node look like the following:
So, instead of UND i:e undefined, I am trying to attach programmatically created arrays of paragraph entities to my nodes.
Can anyone advice how I can modify my code to include my array of Paragraphs data?
Sponsored by SupremePR