1

I am creating a multi-page webform questionaire using the Page wizard.

I have also created a custom handler so I can manipulate the data from the form when completed.

My issue is that when using $webform_submission->getData in the method 'submitForm' in my webform handler class to gather the data, there is no reference to which page the element is from, the array simply contains the element key and value pair.

What would be a proper way of figuring out which page each element is from?

  • Maybe add a hidden field from the UI and then prepopulate it with the current URL using hook_form_alter? – leymannx Sep 9 at 20:59
1

My solution for this in the end was to use a method on the webform object called getPagesWithElements.

// Get webform object
$webform_obj = \Drupal::entityTypeManager()->getStorage('webform')->load('webform_id');
// Get page/element structure
$model = $this->getPagesWithElements($webform_obj);

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.