I've added Computed token field into Webform and it works fine when placing the valid value in 'Computed value/markup' section. However when I've added token which doesn't exist, the field isn't saved, and no validation error is shown.

Checking the request in DevTools shows the following error:

Error: Call to a member function getPages() on null in Drupal\webform\WebformSubmissionForm->getPages() (line 1038 of modules/contrib/webform/src/WebformSubmissionForm.php).

AJAX URL: /admin/structure/webform/manage/book_a_repair/element/computed_token/edit?_wrapper_format=drupal_modal&ajax_form=1&_wrapper_format=drupal_ajax

Backtrace in beta14:

[Thu Jun 29 12:55:42 2017] Error: Call to a member function getPages() on null in modules/contrib/webform/src/WebformSubmissionForm.php on line 1106 #0 modules/contrib/webform/src/WebformSubmissionForm.php(1137): Drupal\webform\WebformSubmissionForm->getPages(Array, Object(Drupal\Core\Form\FormState))
#1 modules/contrib/webform/src/WebformSubmissionForm.php(338): Drupal\webform\WebformSubmissionForm->getCurrentPage(Array, Object(Drupal\Core\Form\FormState))
#2 core/lib/Drupal/Core/Entity/EntityForm.php(115): Drupal\webform\WebformSubmissionForm->form(Array, Object(Drupal\Core\Form\FormState))
#3 modules/contrib/webform/src/WebformSubmissionForm.php(272): Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
#4 [internal function]: Drupal\webform\WebformSubmissionForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
#5 core/lib/Drupal/Core/Form/FormBuilder.php(514): call_user_func_array(Array, Array)
#6 core/lib/Drupal/Core/Form/FormBuilder.php(271): Drupal\Core\Form\FormBuilder->retrieveForm('webform_submiss...', Object(Drupal\Core\Form\FormState))
#7 modules/contrib/webform/src/WebformEntityElementsValidator.php(362): Drupal\Core\Form\FormBuilder->buildForm('webform_submiss...', Object(Drupal\Core\Form\FormState))
#8 modules/contrib/webform/src/WebformEntityElementsValidator.php(108): Drupal\webform\WebformEntityElementsValidator->validateRendering()
#9 modules/contrib/webform/modules/webform_ui/src/Form/WebformUiElementFormBase.php(315): Drupal\webform\WebformEntityElementsValidator->validate(Object(Drupal\webform\Entity\Webform))
#10 [internal function]: Drupal\webform_ui\Form\WebformUiElementFormBase->validateForm(Array, Object(Drupal\Core\Form\FormState))
#11 core/lib/Drupal/Core/Form/FormValidator.php(83): call_user_func_array(Array, Array)
#12 core/lib/Drupal/Core/Form/FormValidator.php(270): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
#13 core/lib/Drupal/Core/Form/FormValidator.php(119): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'webform_ui_elem...')
#14 core/lib/Drupal/Core/Form/FormBuilder.php(571): Drupal\Core\Form\FormValidator->validateForm('webform_ui_elem...', Array, Object(Drupal\Core\Form\FormState))
#15 core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('webform_ui_elem...', Array, Object(Drupal\Core\Form\FormState))
#16 core/lib/Drupal/Core/Controller/FormController.php(74): Drupal\Core\Form\FormBuilder->buildForm('webform_ui_elem...', Object(Drupal\Core\Form\FormState))
#17 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#18 core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#19 core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#20 core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#21 core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#22 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#23 vendor/symfony/http-kernel/HttpKernel.php(144): call_user_func_array(Object(Closure), Array)
#24 vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#25 core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 core/lib/Drupal/Core/DrupalKernel.php(656): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#34 .ht.router.php(45)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kenorb created an issue. See original summary.

jrockowitz’s picture

Status: Active » Postponed (maintainer needs more info)

I can't replicate the issue using the latest dev release.

Can you please documents the steps required to duplicate the issue, with an example of an invalid token.

kenorb’s picture

Version: 8.x-5.0-beta13 » 8.x-5.0-beta14

Same in beta14

Error: Call to a member function getPages() on null in Drupal\webform\WebformSubmissionForm->getPages() (line 1105 of modules/contrib/webform/src/WebformSubmissionForm.php).

My value of computed token field: [block_token:webform:repairs_taps]

It fails on this line:

$pages = $this->getWebform()->getPages($this->mode ? TRUE : FALSE);

and it seems the $this->getWebform() is NULL for some reason.

jrockowitz’s picture

I have idea how to replicate this issue. The block token is handled by another contrib module.

kenorb’s picture

Issue summary: View changes
kenorb’s picture

Issue summary: View changes
kenorb’s picture

Status: Postponed (maintainer needs more info) » Active
FileSize
3.25 MB

Attaching the detailed trace file of mentioned AJAX call which returns getWebform() as NULL. The webform id is book_a_repair, but it looks like it's trying to load something with temp id.

kenorb’s picture

kenorb’s picture

In WebformSubmission.php, $this->webform_id->entity is not set and static::$webform is null.

jrockowitz’s picture

Status: Active » Needs review
FileSize
642 bytes

The attached patch fixes the fatal error. I am not exactly sure what you are using the [block_token] for.

  • jrockowitz committed b810bd1 on 8.x-5.x
    Issue #2890522 by jrockowitz, kenorb: Call to a member function getPages...
jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch but I am not sure it solves your issue.

kenorb’s picture

@jrockowitz Thank you, it works. It would take me ages to find out what's going on. Basically I'm using block_token to test the idea of loading webform within webform, so webform has Computed token handled by block_token:webform which will render another webform. The goal is for the user to select from the dropdown another set of webform questions.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.