Undefined array key "#date_date_element" with datetime element and webform_jqueryui_datepicker

Created on 10 January 2023, almost 2 years ago
Updated 3 April 2024, 8 months ago

Problem/Motivation

Create a new standard installation of Drupal 9.5.0
composer require drupal/webform:^6.2@beta
composer require drupal/jquery_ui_datepicker
drush en webform_jqueryui_datepicker webform_ui -y
Log in as user 1
Go to /admin/structure/webform
New webform "test"

Create webform with:

test:
  '#type': datetime
  '#title': test
  '#multiple__no_items_message': '<p>No items entered. Please add items below.</p>'
  '#format_items': comma

You will now see

Error message
Warning: Undefined array key "#date_date_element" in _webform_entity_element_validate_rendering_error_handler() (line 1107 of modules/custom/webform/webform.module).
_webform_entity_element_validate_rendering_error_handler(2, 'Undefined array key "#date_date_element"', '/var/www/html/modules/custom/webform/modules/webform_jqueryui_datepicker/webform_jqueryui_datepicker.module', 195) (Line: 195)
webform_jqueryui_datepicker_webform_element_alter(Array, Object, Array) (Line: 562)
Drupal\Core\Extension\ModuleHandler->alter('webform_element', Array, Object, Array) (Line: 184)
Drupal\webform\Plugin\WebformElementManager->buildElement(Array, Array, Object) (Line: 2572)
Drupal\webform\WebformSubmissionForm->prepareElements(Array, Array, Object) (Line: 828)
Drupal\webform\WebformSubmissionForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object) (Line: 641)
Drupal\webform\WebformSubmissionForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 534)
Drupal\Core\Form\FormBuilder->retrieveForm('webform_submission_test_add_form', Object) (Line: 281)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 570)
Drupal\webform\WebformEntityElementsValidator->validateRendering() (Line: 217)
Drupal\webform\WebformEntityElementsValidator->validate(Object) (Line: 137)
Drupal\webform\WebformEntityElementsForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'webform_source_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('webform_source_form', Array, Object) (Line: 591)
Drupal\Core\Form\FormBuilder->processForm('webform_source_form', Array, Object) (Line: 323)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, 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: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->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: 707)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

See above.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

6.2

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada alberto56

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

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

  • πŸ‡ΊπŸ‡ΈUnited States loopy1492

    I have 6.2.0-beta-5 installed and I'm getting this on our webforms. That version seems to have the code from this issue in it. Does anyone have any thoughts?

    We are running php 8.1 and drupal 9.5.7.

    Warning: Undefined array key "#date_time_element" in template_preprocess_datetime_form() (line 577 of /var/www/html/docroot/core/includes/theme.inc)
    #0 /var/www/html/docroot/core/includes/bootstrap.inc(347): _drupal_error_handler_real()
    #1 /var/www/html/docroot/core/includes/theme.inc(577): _drupal_error_handler()
    #2 [internal function]: template_preprocess_datetime_form()
    #3 /var/www/html/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(287): call_user_func_array()
    #4 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
    #5 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
    #6 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
    #7 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
    #8 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
    #9 /var/www/html/docroot/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render()
    #10 /tmp/startheregettheredev/php_storage/twig/pipelines-build-pr-186/startheregetthere/twig/643edd8b733f6_webform-submission-form.h_jJWHssFb3bwZVySGcxBYijPOr/AKi8cE3l0Rq7p_ye5KMMnVHLTIM5DRS_qShyKKdARQA.php(39): Drupal\Core\Template\TwigExtension->escapeFilter()
    #11 /var/www/html/vendor/twig/twig/src/Template.php(405): __TwigTemplate_d0a1999f3428136208cf7bc4e3d9cfb4->doDisplay()
    #12 /var/www/html/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling()
    #13 /var/www/html/vendor/twig/twig/src/Template.php(390): Twig\Template->display()
    #14 /var/www/html/docroot/core/themes/engines/twig/twig.engine(55): Twig\Template->render()
    #15 /var/www/html/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
    #16 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
    #17 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
    #18 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
    #19 /var/www/html/docroot/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render()
    #20 /tmp/startheregettheredev/php_storage/twig/pipelines-build-pr-186/startheregetthere/twig/643edd8b733f6_field.html.twig_OQsfDFeEXuYfjCxX4OapDYrvT/hkw-Ok7A5YRg1JrJaEePF081nSKT2nS6eX574_E9drk.php(88): Drupal\Core\Template\TwigExtension->escapeFilter()
    #21 /var/www/html/vendor/twig/twig/src/Template.php(405): __TwigTemplate_3a5ed793940105357c458e51cf06bc04->doDisplay()
    #22 /var/www/html/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling()
    #23 /var/www/html/vendor/twig/twig/src/Template.php(390): Twig\Template->display()
    #24 /var/www/html/docroot/core/themes/engines/twig/twig.engine(55): Twig\Template->render()
    #25 /var/www/html/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
    #26 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
    #27 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
    #28 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
    #29 /var/www/html/docroot/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render()
    #30 /tmp/startheregettheredev/php_storage/twig/pipelines-build-pr-186/startheregetthere/twig/643edd8b733f6_node.html.twig_dp1GjU0nDShHudoP2hm_4OLUy/p-JoezQ2-JZRHdu_C6IE2bDxm5ZssSB08ARrSqXAjVg.php(100): Drupal\Core\Template\TwigExtension->escapeFilter()
    #31 /var/www/html/vendor/twig/twig/src/Template.php(405): __TwigTemplate_b7294825e96b4e24ada13fdf7bef2fba->doDisplay()
    #32 /var/www/html/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling()
    #33 /var/www/html/vendor/twig/twig/src/Template.php(390): Twig\Template->display()
    #34 /var/www/html/docroot/core/themes/engines/twig/twig.engine(55): Twig\Template->render()
    #35 /var/www/html/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
    #36 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
    #37 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
    #38 /var/www/html/docroot/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(242): Drupal\Core\Render\Renderer->render()
    #39 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
    #40 /var/www/html/docroot/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(243): Drupal\Core\Render\Renderer->executeInRenderContext()
    #41 /var/www/html/docroot/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(132): Drupal\Core\Render\MainContent\HtmlRenderer->prepare()
    #42 /var/www/html/docroot/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()
    #43 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
    #44 /var/www/html/docroot/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
    #45 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(174): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
    #46 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #47 /var/www/html/docroot/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(68): Symfony\Component\HttpKernel\HttpKernel->handle()
    #48 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle()
    #49 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #50 /var/www/html/docroot/modules/contrib/shield/src/ShieldMiddleware.php(270): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #51 /var/www/html/docroot/modules/contrib/shield/src/ShieldMiddleware.php(226): Drupal\shield\ShieldMiddleware->bypass()
    #52 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\shield\ShieldMiddleware->handle()
    #53 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #54 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #55 /var/www/html/docroot/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
    #56 /var/www/html/docroot/index.php(19): Drupal\Core\DrupalKernel->handle()
    #57 {main}

  • πŸ‡ΊπŸ‡ΈUnited States loopy1492

    It's possible it has to do with using tokens in the title of a fieldset:

    callback_time:
        '#type': fieldset
        '#title': 'Reservation Request for [webform_submission:node:field_reservation_form_date:date:custom:l, F j, Y:clear]'
        representative_name:
          '#type': webform_computed_token
          '#title': 'Loan Representative'
          '#wrapper_attributes':
            style: 'display: none'
            etc.....
    
  • πŸ‡ΊπŸ‡ΈUnited States loopy1492

    I was wrong. This seems to be happening when I use the "Date List" element type. When I switch to "Date", the error goes away. Is it possible that the datepicker is trying to apply itself to a field that shouldn't be using a datepicker? I think perhaps I need to make a new issue.

  • πŸ‡¬πŸ‡§United Kingdom entropea

    Also seeing this in latest version with D10. Fine when using Date type, but when datelist is used we see this warning.

Production build 0.71.5 2024