Problem/Motivation
We are using the Webform Element in a form on our site and we are getting a error on submission. The error is as follows:
TypeError: Unsupported operand types: array + null in Drupal\office_hours\Element\OfficeHoursBaseSlot::validateOfficeHoursSlot() (line 247 of modules/contrib/office_hours/src/Element/OfficeHoursBaseSlot.php).
Drupal\office_hours\Element\OfficeHoursBaseSlot::validateOfficeHoursSlot(Array, Object, Array) (Line: 165)
Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours::validateOfficeHoursSlot(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 282)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 238)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 238)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 238)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'webform_submission_one_to_one_learner_registration__test_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('webform_submission_one_to_one_learner_registration__test_form', Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('webform_submission_one_to_one_learner_registration__test_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'test') (Line: 1249)
Drupal\webform\Entity\Webform->getSubmissionForm(Array, 'test') (Line: 128)
Drupal\webform\Controller\WebformTestController->testForm(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
As far as the config options for the element itself, this error persists no matter what options one chooses for it when building the form.
Steps to reproduce
- Create a webform (or edit an existing form)
- Add an Office Hours element to the form
- Attempt a test submission for the form
Comments
Comment #2
lordbarnhill commentedComment #3
johnvHow com thisis a new error?
- new installation,
- upgrade of PHP version? (What is you current PHP version, since checks are more strict)
- upgrade of Office hours module?
working on the problem..
Comment #4
johnvComment #6
johnvThis should be fixed. Please test newest DEV-version, or above patch.
Comment #7
lordbarnhill commentedThanks for the quick response! I tested with the patch from #4 and got the following error:
To answer you questions from #3:
- This is on an existing site, not a new installation
- The PHP version is 8.1
- We recently updated the Office Hours module from 8.x-1.8 (I believe) to 8.x-1.9
Comment #8
lordbarnhill commentedComment #9
lordbarnhill commentedComment #10
johnvhmm.
I guess there is some 'strict_typing' activated by one of your installed modules.
And as you have only 1 error at a time, this will bounce more often. :-(
Can you debug and check what is the contents of '$this->settings['exceptions']' ?
Else, you can save the field formatter settings. That should fix the problem , too. But that is not solution for other people with your settings.
Comment #11
lordbarnhill commentedThe content of
$this->settings['exceptions']is showing to beFALSE.Comment #13
johnvPlease see attached patch for this new occasion.
Comment #15
lordbarnhill commentedUsing both the #4 and #13 patches allowed the form to be submitted successfully. However, now I am seeing an error when trying to view the submission:
I am also seeing a warning after submitting the form:
Comment #16
johnvUnfortunately, I cannot reproduce your problem, working with Drupal 9.5.x and latest Webform version and PHP8.2.
Yesterday, a new version 1.11 is released. Please test again with that release.
Please also see attached new patch, regarding Warning: Undefined array key "day" . I will commit that change shortly.
I created Webformsubmissions from beow pages, and none call the viewElements() function. Only prepare() is called.
/form/TYPE
/webform/TYPE/test
Can you state your complete test script? I think is is used when downloading webform submissions.
Comment #18
johnvOK, your error appears on the following page:
admin/structure/webform/manage/TYPE/results/submissions
Comment #19
johnvPlease test attached patch.
Or download dev, since I will commit it shortly.
Comment #20
johnvComment #24
lordbarnhill commentedI tested with the newest version (v1.11) and the patches from #16 and #20 and all the errors seem to be resolved! I am now able to submit the form successfully and view the submissions at
admin/structure/webform/manage/TYPE/results/submissions. Thank you for being so responsive with this issue!Comment #25
johnvDe nada.
Comment #26
johnv