Account created on 15 November 2016, over 7 years ago
#

Recent comments

Applying the src/OfficeHoursDateHelper.php part of the patch did fix the problem on the site I was testing on.

Sorry for the delay in responding.

So, in 'Manage display', it does not matter how the time notation is?

Correct, this happens no matter what the time notation setting is in "Manage display."

So you problem is that your ampm input allows number 13-24. Correct?
Not sure why this would only occur between 13:00 (that I understand) and 17:40 (that I do NOT understand).

No, that isn't it. What is happening is this: if the start time for a day is set to any time between 12:01pm and 12:59pm and the end time is set to a time between 1:00pm and 7:40pm an error will be thrown when you try to save the node. An error that reads, "The Day: Closing hours are earlier than Opening hours," will display at the top of the page for each day that has start and end times within the those ranges. The start and end times set in my case were 12:15pm and 5:45pm. I looked for that error in the module code and found it in OfficeHoursBaseSlot.php on lines 279-281. I then found the two variables the conditional was comparing ($start and $end, located on lines 251 and 252) and then printed the value of those variables to the screen (with dpm()). The value for $start was 1940 when it should be 1215 and the value for $end was 1745 which is correct (the times are converted in the code it seems). If I change the start time to any time that is not in the previously mentioned range then $start has a value that correctly equates to the time. For example, if I change the start time to 1:30pm then the value in $start will be 1330 as it should be and if I set the time to 12:00pm the value in $start will be 1200 like it should be.

The value in $end will also be 1940 if the end time for a day is set to a time between 12:01pm and 12:59pm. Not an issue in this particular instance but still an issue as well.

Here is a screenshot of the field settings:

Here is a screenshot of the widget on the edit page:

And here is an image of the Error at the top of the edit page after trying to save:

I tested with the newest version (v1.11) and the patches from #16 🐛 Webform #Element_validate: Unsupported operand types Fixed and #20 🐛 Webform #Element_validate: Unsupported operand types Fixed 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!

Using both the #4 🐛 Webform #Element_validate: Unsupported operand types Fixed and #13 🐛 Webform #Element_validate: Unsupported operand types Fixed patches allowed the form to be submitted successfully. However, now I am seeing an error when trying to view the submission:

The website encountered an unexpected error. Please try again later.
TypeError: Drupal\Core\TypedData\TypedDataManager::create(): Argument #1 ($definition) must be of type Drupal\Core\TypedData\DataDefinitionInterface, null given, called in /app/web/modules/contrib/office_hours/src/Plugin/WebformElement/WebformOfficeHours.php on line 384 in Drupal\Core\TypedData\TypedDataManager->create() (line 99 of core/lib/Drupal/Core/TypedData/TypedDataManager.php).
Drupal\Core\TypedData\TypedDataManager->create(NULL, Array, 'availability', Object) (Line: 384)
Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours->unserialize(Array, Array, Object) (Line: 194)
Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours->viewElements(Array, Object, Array) (Line: 219)
Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours->formatHtmlItem(Array, Object, Array) (Line: 1377)
Drupal\webform\Plugin\WebformElementBase->format('Html', Array, Object, Array) (Line: 1327)
Drupal\webform\Plugin\WebformElementBase->formatHtml(Array, Object, Array) (Line: 344)
Drupal\webform\Plugin\WebformElement\WebformCompositeBase->formatHtml(Array, Object) (Line: 279)
Drupal\webform\Plugin\WebformElement\WebformCompositeBase->formatTableColumn(Array, Object, Array) (Line: 1001)
Drupal\webform\WebformSubmissionListBuilder->buildRowColumn(Array, Object) (Line: 834)
Drupal\webform\WebformSubmissionListBuilder->buildRow(Object) (Line: 219)
Drupal\Core\Entity\EntityListBuilder->render() (Line: 559)
Drupal\webform\WebformSubmissionListBuilder->buildEntityList() (Line: 454)
Drupal\webform\WebformSubmissionListBuilder->render() (Line: 23)
Drupal\Core\Entity\Controller\EntityListController->listing('webform_submission')
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)

I am also seeing a warning after submitting the form:

Warning: Undefined array key "day" in Drupal\office_hours\Element\OfficeHoursBaseSlot::validateOfficeHoursSlot() (line 243 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)

The content of $this->settings['exceptions'] is showing to be FALSE.

Thanks for the quick response! I tested with the patch from #4 🐛 Webform #Element_validate: Unsupported operand types Fixed and got the following error:

TypeError: Unsupported operand types: bool + array in Drupal\office_hours\Plugin\Field\FieldFormatter\OfficeHoursFormatterBase->mergeDefaults() (line 99 of modules/contrib/office_hours/src/Plugin/Field/FieldFormatter/OfficeHoursFormatterBase.php).
Drupal\office_hours\Plugin\Field\FieldFormatter\OfficeHoursFormatterBase->mergeDefaults() (Line: 51)
Drupal\Core\Field\PluginSettingsBase->getSettings() (Line: 45)
Drupal\office_hours\Plugin\Field\FieldFormatter\OfficeHoursFormatterDefault->viewElements(Object, NULL) (Line: 208)
Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours->viewElements(Array, Object, Array) (Line: 232)
Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours->formatTextItem(Array, Object, Array) (Line: 1377)
Drupal\webform\Plugin\WebformElementBase->format('Text', Array, Object, Array) (Line: 1334)
Drupal\webform\Plugin\WebformElementBase->formatText(Array, Object, Array) (Line: 356)
Drupal\webform\Plugin\WebformElement\WebformCompositeBase->formatText(Array, Object, Array) (Line: 1295)
Drupal\webform\Plugin\WebformElementBase->build('text', Array, Object, Array) (Line: 1274)
Drupal\webform\Plugin\WebformElementBase->buildText(Array, Object, Array) (Line: 196)
Drupal\webform\WebformSubmissionViewBuilder->buildElements(Array, Object, Array, 'text') (Line: 193)
Drupal\webform\Plugin\WebformElement\ContainerBase->formatTextItem(Array, Object, Array) (Line: 1377)
Drupal\webform\Plugin\WebformElementBase->format('Text', Array, Object, Array) (Line: 1334)
Drupal\webform\Plugin\WebformElementBase->formatText(Array, Object, Array) (Line: 83)
Drupal\webform\Plugin\WebformElement\ContainerBase->build('text', Array, Object, Array) (Line: 1274)
Drupal\webform\Plugin\WebformElementBase->buildText(Array, Object, Array) (Line: 196)
Drupal\webform\WebformSubmissionViewBuilder->buildElements(Array, Object, Array, 'text') (Line: 1119)
_webform_token_get_submission_values(Array, Object) (Line: 599)
webform_tokens('webform_submission', Array, Array, Array, Object)
call_user_func_array(Object, Array) (Line: 426)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'webform') (Line: 405)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('tokens', Object) (Line: 433)
Drupal\Core\Extension\ModuleHandler->invokeAll('tokens', Array) (Line: 359)
Drupal\Core\Utility\Token->generate('webform_submission', Array, Array, Array, Object) (Line: 241)
Drupal\Core\Utility\Token->doReplace(1, 'Submitted on [webform_submission:created]
Submitted by: [webform_submission:user]

Submitted values are:
[webform_submission:values]
', Array, Array, Object) (Line: 191)
Drupal\Core\Utility\Token->replace('Submitted on [webform_submission:created]
Submitted by: [webform_submission:user]

Submitted values are:
[webform_submission:values]
', Array, Array, Object) (Line: 154)
Drupal\webform\WebformTokenManager->replace('Submitted on [webform_submission:created]
Submitted by: [webform_submission:user]

Submitted values are:
[webform_submission:values]
', Object, Array, Array, Object) (Line: 173)
Drupal\webform\WebformTokenManager->replaceNoRenderContext('Submitted on [webform_submission:created]
Submitted by: [webform_submission:user]

Submitted values are:
[webform_submission:values]
', Object, Array, Array) (Line: 746)
Drupal\webform\Plugin\WebformHandlerBase->replaceTokens('Submitted on [webform_submission:created]
Submitted by: [webform_submission:user]

Submitted values are:
[webform_submission:values]
', Object, Array, Array) (Line: 930)
Drupal\webform\Plugin\WebformHandler\EmailWebformHandler->getMessage(Object) (Line: 857)
Drupal\webform\Plugin\WebformHandler\EmailWebformHandler->postSave(Object, , NULL) (Line: 2757)
Drupal\webform\Entity\Webform->invokeHandlers('postSave', Object, , NULL) (Line: 1212)
Drupal\webform\WebformSubmissionStorage->invokeWebformHandlers('postSave', Object, ) (Line: 1120)
Drupal\webform\WebformSubmissionStorage->doPostSave(Object, ) (Line: 523)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 804)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 983)
Drupal\webform\WebformSubmissionStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 901)
Drupal\webform\Entity\WebformSubmission->save() (Line: 1995)
Drupal\webform\WebformSubmissionForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
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)

To answer you questions from #3 🐛 Webform #Element_validate: Unsupported operand types Fixed :
- 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

Production build 0.69.0 2024