Error for Office Hours element in a Webform

Created on 17 September 2024, 4 months ago
Updated 19 September 2024, 4 months ago

Problem/Motivation

We are encountering the following error on Webforms that have an Office Hours element added to them. The error occurs whether the form element has hours added to it or not and it only occurs when trying to submit the form.

Error: Call to a member function getValue() on null in Drupal\office_hours\Element\OfficeHoursBaseSlot::validateOfficeHoursSlot() (line 256 of modules/contrib/office_hours/src/Element/OfficeHoursBaseSlot.php).
Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours::validateOfficeHoursSlot(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 281)
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_test_add_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('webform_submission_test_add_form', Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('webform_submission_test_add_form', Array, Object) (Line: 326)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'add') (Line: 1250)
Drupal\webform\Entity\Webform->getSubmissionForm() (Line: 89)
Drupal\webform\Controller\WebformEntityController->addForm(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->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: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Create a new webform (or edit an existing one) and add an Office Hours element to the form. Alternatively, I have attached a YML file for a test form you can import. The test form that will be imported only contains an Office Hours field with the default settings.

Test the form by filling out the hours on in the Office Hours element or, if you did not make that element required, simply click submit. You should be met with the error mentioned above in either case.

🐛 Bug report
Status

Postponed: needs info

Version

1.17

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @LordBarnhill
  • 🇳🇱Netherlands johnv

    Please check if the error still appears in the new version 1.18. Thanks.

  • Status changed to Postponed: needs info 4 months ago
  • With the new version I am seeing two new errors and only the table headings render for the form element. The errors I am seeing are:

    Warning: Undefined array key "#webform_key" in Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours->prepare() (line 153 of modules/contrib/office_hours/src/Plugin/WebformElement/WebformOfficeHours.php).
    Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours->prepare(Array, Object) (Line: 173)
    Drupal\webform\Plugin\WebformElementManager->buildElement(Array, Array, Object) (Line: 2594)
    Drupal\webform\WebformSubmissionForm->prepareElements(Array, Array, Object) (Line: 835)
    Drupal\webform\WebformSubmissionForm->form(Array, Object) (Line: 107)
    Drupal\Core\Entity\EntityForm->buildForm(Array, Object) (Line: 648)
    Drupal\webform\WebformSubmissionForm->buildForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 536)
    Drupal\Core\Form\FormBuilder->retrieveForm('webform_submission_test_add_form', Object) (Line: 284)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
    Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'add') (Line: 1250)
    Drupal\webform\Entity\Webform->getSubmissionForm() (Line: 89)
    Drupal\webform\Controller\WebformEntityController->addForm(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->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: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    and

    Warning: Undefined array key "value" in Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours->prepare() (line 153 of modules/contrib/office_hours/src/Plugin/WebformElement/WebformOfficeHours.php).
    Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours->prepare(Array, Object) (Line: 173)
    Drupal\webform\Plugin\WebformElementManager->buildElement(Array, Array, Object) (Line: 2594)
    Drupal\webform\WebformSubmissionForm->prepareElements(Array, Array, Object) (Line: 835)
    Drupal\webform\WebformSubmissionForm->form(Array, Object) (Line: 107)
    Drupal\Core\Entity\EntityForm->buildForm(Array, Object) (Line: 648)
    Drupal\webform\WebformSubmissionForm->buildForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 536)
    Drupal\Core\Form\FormBuilder->retrieveForm('webform_submission_test_add_form', Object) (Line: 284)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
    Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'add') (Line: 1250)
    Drupal\webform\Entity\Webform->getSubmissionForm() (Line: 89)
    Drupal\webform\Controller\WebformEntityController->addForm(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->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: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    • johnv committed 147d7611 on 8.x-1.x
      Issue #3474979: Error messages in WebformOfficeHours element
      
  • 🇳🇱Netherlands johnv

    Not sure what happened here. It seems like a regression error in a recent version.
    The commit should fix the problem. Tested against Webform 6.2.7

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

Production build 0.71.5 2024