Undefined array key "type" in Drupal\Core\Render\Element\Date::processDate()

Created on 6 March 2023, over 1 year ago
Updated 13 September 2023, 10 months ago

Problem/Motivation

When the views containing date expose filters has rendered for the first time, we get this warning:

Warning: Undefined array key "type" in Drupal\Core\Render\Element\Date::processDate() (line 71 of core/lib/Drupal/Core/Render/Element/Date.php).

Steps to reproduce

On Drupal 9.5.3

  1. enable the date_popup module
  2. create a custom view with at least one date exposed filter.

Proposed resolution

Add $element['#attributes']['type'] = 'date'; in the DatePopupTrait

Remaining tasks

Create the patch.

🐛 Bug report
Status

Fixed

Version

1.3

Component

Code

Created by

🇮🇹Italy robertoperuzzo 🇮🇹 Tezze sul Brenta, VI

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.

  • 🇦🇷Argentina tongadall

    In yout patch #3 the second $element['min']['#attributes']['type'] = 'date'; should be ['max'] I guess.

  • 🇮🇹Italy robertoperuzzo 🇮🇹 Tezze sul Brenta, VI

    @tongadall you are right!

    Here is the fixing patch.

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    Waiting for branch to pass
  • 🇮🇹Italy robertoperuzzo 🇮🇹 Tezze sul Brenta, VI
  • 🇮🇳India Raveen Kumar

    I have reviewed and applied patch #5 on my Drupal version - 9.5.1 and PHP version 8.1. The Patch is working fine for me as well. Thank You.

  • Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    Waiting for branch to pass
  • 🇮🇹Italy robertoperuzzo 🇮🇹 Tezze sul Brenta, VI

    I did another patch to use input type="datetime-local", if could be useful for someone.

    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime...

  • 🇺🇸United States attheshow

    Patch #5 is working for us.

  • 🇪🇸Spain JoseCarlosss

    Patch #5 works, thanks you!

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    Build Successful
  • 🇦🇹Austria maxilein

    Patch #5 works, thanks you!

  • 🇦🇹Austria maxilein

    The patch does not apply to the latest dev-1.x nor to 2.0

    Is it still required?

  • 🇦🇹Austria maxilein

    Obviously it is stll required for dev-1.x ...

  • 🇦🇹Austria maxilein

    and also 2.0...

  • 🇦🇹Austria maxilein

    The error has gotten worse ...

    The website encountered an unexpected error. Please try again later.
    
    ArgumentCountError: Too few arguments to function Drupal\date_popup\DateRangePopup::applyDatePopupToForm(), 1 passed in /var/www/web/modules/contrib/date_popup/src/DateRangePopup.php on line 20 and exactly 2 expected in Drupal\date_popup\DateRangePopup::applyDatePopupToForm() (line 40 of modules/contrib/date_popup/src/DatePopupTrait.php).
    
    Drupal\date_popup\DateRangePopup->buildExposedForm() (Line: 111)
    Drupal\views\Form\ViewsExposedForm->buildForm()
    call_user_func_array() (Line: 536)
    Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 283)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 134)
    Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase->renderExposedForm() (Line: 1253)
    Drupal\views\ViewExecutable->build() (Line: 392)
    Drupal\views\Plugin\views\display\PathPluginBase->execute() (Line: 196)
    Drupal\views\Plugin\views\display\Page->execute() (Line: 1645)
    Drupal\views\ViewExecutable->executeDisplay() (Line: 81)
    Drupal\views\Element\View::preRenderViewElement()
    call_user_func_array() (Line: 111)
    Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 788)
    Drupal\Core\Render\Renderer->doCallback() (Line: 377)
    Drupal\Core\Render\Renderer->doRender() (Line: 204)
    Drupal\Core\Render\Renderer->render() (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 583)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 239)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
    call_user_func() (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 171)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 74)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    
    
  • 🇦🇹Austria maxilein

    crashes site with internal error...

  • Status changed to Active 11 months ago
  • 🇨🇾Cyprus gregcy

    Attached is the patch from #5 but for version 2.x of the module.

  • 🇺🇸United States jimmynash

    Tested patch in #19 and it cleared the problem for me after a fresh install of 2.0.0

    Thanks!

  • Status changed to Fixed 10 months ago
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Thanks, cutting 2.0.1

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

Production build 0.69.0 2024