-1

I would like to extract the value entered by the user in a form to use it in a custom module. I use Drupal 8.5.1 and Webform 8.x-5.0-rc10. Thanks!

2

If you are using a form alter hook you can user $form_state->getValue('element_name'). If you are want to get the final submission's data you could do...

$form_object = $form_state->getFormObject();
$webform_submission = ($form_object instanceof WebformSubmissionForm) ? $form_object->getEntity() : NULL;
$value = $webform_submission->getElementData('element_name');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.