- 🇫🇮Finland tvalimaa
I have same issue that content type is using paragraphs. I think it's just easier and fastest just create custom module and use this module code base for some help. Basic idea is just use webform submission hook and tigger own custom function to create node programmatically without any UI mapping or settings. Other thing what I can do is extend this module code and override mapping part but maybe simple submission hook + custom node creating is fastest.
- 🇩🇪Germany JoCowood Kamp-Lintfort
Hey tvalimaa, I think your approach is very good. It contains only a few errors, which I have corrected. In addition, the method signature of mapEntityField has changed. I have adjusted that as well. Please excuse that I am more a fan of the snakecase :-)
/** * {@inheritdoc} */ public function mapEntityField(ContentEntityInterface &$content, array $webform_element, FieldDefinitionInterface $field_definition, array $data = [], array $attributes = []) { $fieldId = $field_definition->getName(); $paragraphFieldValue = $data[$fieldId]; if (!empty($paragraphFieldValue)) { $paragraph = Paragraph::create([ 'type' => 'text', 'field_text' => [ 'value' => $paragraphFieldValue, 'format' => 'full_html' ], ]); $paragraph->save(); $fieldValue[] = [ 'target_id' => $paragraph->id(), 'target_revision_id' => $paragraph->getRevisionId(), ]; $content->set($fieldId, $fieldValue); } }
- 🇵🇹Portugal joaomarques736
Hello all,
Considering the new plugin system, it can be extended to create the plugins for any type of complex field, including paragraphs.
Best regards.
- Status changed to Closed: works as designed
7 months ago 10:23pm 27 April 2024