- 🇺🇸United States nathanhealea
Has anyone figured this out? Im working on a similar problem.
need to add Paragraph fields programmatically to an entity in an AJAX handler.
This is my AJAX callback:
function myAjaxCallback(array &$form, \Drupal\Core\Form\FormState $form_state) {
$paragraph3 = \Drupal\paragraphs\Entity\Paragraph::create([
'type' => 'media',
'field_caption' => 'Apart from the included Paragraph types, you can create your own simply by going to Structure -> Paragraphs types.',
]);
$paragraph3->save();
// Now I need to add $paragraph3 to $form['field_gallery_items']['widget']
return $form;
}
I need to add the new Paragraph I created to the widget so that when the $form is returned I have added a paragraph.
How Can I do that?
Active
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Has anyone figured this out? Im working on a similar problem.