Save paragraph widget data in custom form

Created on 5 March 2019, almost 6 years ago
Updated 23 January 2024, about 1 year ago

I am adding a node paragraph field widget in a custom form:

<?php
$site_settings_node = Node::load($node_id);
$entity_form_display = \Drupal::service('entity_type.manager')->getStorage('entity_form_display')
  ->load('node.node_type.default');
if ($widget = $entity_form_display->getRenderer('field_my_field')) {
  $items = $site_settings_node->get('field_my_field');
  $items->filterEmptyItems();
  $form['#parents'] = array();
  $form['custom_form_field'] = $widget->form($items, $form, $form_state);
}
?>

How do I update the paragraph field values in my submit handler? Is there something like the below that I can do?

<?php
$widget = $entity_form_display->getRenderer('field_my_field')
$widget->submit($items, $form, $form_state);
?>
💬 Support request
Status

Closed: won't fix

Version

1.6

Component

Code

Created by

🇬🇧United Kingdom tce

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
Production build 0.71.5 2024