Answer the question
In order to leave comments, you need to log in
Module for creating a node from Webform fields?
Hey! the task arose on Drupal8 software to create material from the fields filled in the form, I have not yet written modules but I want to learn) please tell me the beginning of the process.
I created a module, enabled it, added a hook in the name.module file
/**
* Implements hook_webform_insert().
*/
function add_dive_webform_insert(\Drupal\webform\WebformInterface $webform) {
$node = \Drupal\node\entity\Node::create([
'type' => 'NAME-NODE',
'title' => $webform->label(),
'webform' => ['target_id' => $webform->id()],
]);
$node->save();
drupal_set_message(t('Node %label created.', ['%label' => $node->label()]));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question