Score:0

Webform get submission details after or during submission

eg flag

How can I access the form data during or after submission?

Am using Webform REST for the submission of forms, but I don't seem to be able to retrieve the form data.

For now, I tried the following which gives me empty results:

function module_webform_submission_form_alter(array &$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  \Drupal::logger("module.webform.data")->notice(json_encode($form_state, true));
}

I tried using HOOK form submit but it does not log anything at all. In fact, it looks like this hook is not triggered.

function module_webform_submit($form, \Drupal\Core\Form\FormStateInterface $form_state) {
  \Drupal::logger("module.webform.form_state")->notice(json_encode($form_state, true));
} 

How can I access the form data during or after submission?

Ivaylo Tsandev avatar
us flag
One thing you could do is to create a custom Plugin and use it as a submit handler. This way you'd have all the information you need. You may see example here: https://www.drupal.org/docs/8/modules/webform/webform-cookbook/how-to-add-custom-validation-to-a-webform-element#s-method-2-using-webform-handlers
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.