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

Comments

alberto56 created an issue. See original summary.

jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new4.94 KB

I am not able to replicate this issue using the attached webform.

alberto56’s picture

Status: Needs review » Postponed (maintainer needs more info)

Thanks, I assume you meant to use the status "postponed (maintainer needs more info)" so I set it to that.

I will add that I am using PHP 8.1 which might explain why you're not seeing the issue. On a brand new Drupal site with that webform, I am seeing the problem, and in addition, the datepicker does not appear resulting in mismatched date formats.

My workaround is to to use a "date" only field (not "datetime") and then a separate field for the time.

jrockowitz’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new971 bytes

I can't replicate the error, but I can see the issue via the code.

If all the tests pass, I will commit the patch.

jrockowitz’s picture

Status: Needs review » Fixed
alberto56’s picture

Thanks!

  • jrockowitz authored 0fdca76a on 6.2.x
    Issue #3332440 by jrockowitz: Undefined array key "#date_date_element"...

Status: Fixed » Closed (fixed)

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

loopy1492’s picture

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().... truncated

loopy1492’s picture

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.....
loopy1492’s picture

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.

entropea’s picture

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