Getting this Warning: Undefined array key "#type" in Drupal\Core\Form\FormHelper::processStates()

Created on 31 July 2023, over 1 year ago
Updated 18 September 2024, 3 months ago

Problem/Motivation

Drupal 9.5.3, PHP 8.1

Warning: Undefined array key "#type" in Drupal\Core\Form\FormHelper::processStates() (line 211 of core\lib\Drupal\Core\Form\FormHelper.php).

Steps to reproduce

Install Module

Here are the steps:

  1. Install and enable the "Views Date Filter" module.
  2. Create a new View or edit an existing View.
  3. Adds datepickers for exposed filter value selection.
  4. Replaces the "min" and "max" field labels for between option with "from" and "to".
  5. Removes the obsolete input type selection (offset or date).
  6. In case of offset default values - maps them to dates in exposed filters datepickers.

Proposed resolution

This module is working. But this warning will be displayed on the page,

Warning: Undefined array key "#type" in Drupal\Core\Form\FormHelper::processStates()

Unable to resolve this warning!

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India nik@10 Noida

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

  • Issue created by @nik@10
  • 🇮🇳India shailja179 India

    @nik@10,
    Please provide the steps to reproduce.

  • 🇮🇳India nik@10 Noida

    Drupal 9.5.3, PHP 8.1

    Warning: Undefined array key "#type" in Drupal\Core\Form\FormHelper::processStates() (line 211 of core\lib\Drupal\Core\Form\FormHelper.php).

  • 🇧🇪Belgium kenowax Mons

    Getting the same error on Drupal 9.5.11 and PHP 8.0 and using GIN theme.
    Here's the stack trace :

    Warning: Undefined array key "#type" in Drupal\Core\Form\FormHelper::processStates() (line 211 of core/lib/Drupal/Core/Form/FormHelper.php).
    Drupal\Core\Form\FormHelper::processStates(Array) (Line: 400)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
    Drupal\Core\Render\Renderer->render(Array) (Line: 479)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 48)
    __TwigTemplate_531709720117ade972a1c60ffaab7ba1->doDisplay(Array, Array) (Line: 405)
    Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
    Twig\Template->display(Array) (Line: 390)
    Twig\Template->render(Array) (Line: 55)
    twig_render_template('core/themes/claro/templates/views-exposed-form.html.twig', Array) (Line: 384)
    Drupal\Core\Theme\ThemeManager->render('views_exposed_form', Array) (Line: 433)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
    Drupal\Core\Render\Renderer->render(Array) (Line: 479)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 84)
    __TwigTemplate_b9ee8384123b126456837bfa34e06538->doDisplay(Array, Array) (Line: 405)
    Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
    Twig\Template->display(Array) (Line: 390)
    Twig\Template->render(Array) (Line: 55)
    twig_render_template('themes/contrib/gin/templates/views/views-view.html.twig', Array) (Line: 384)
    Drupal\Core\Theme\ThemeManager->render('views_view', Array) (Line: 433)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
    Drupal\Core\Render\Renderer->render(Array) (Line: 479)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 80)
    __TwigTemplate_5c0281f896044c86f187782b384e1e10->block_content(Array, Array) (Line: 182)
    Twig\Template->displayBlock('content', Array, Array) (Line: 68)
    __TwigTemplate_5c0281f896044c86f187782b384e1e10->doDisplay(Array, Array) (Line: 405)
    Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
    Twig\Template->display(Array) (Line: 390)
    Twig\Template->render(Array) (Line: 55)
    twig_render_template('core/themes/claro/templates/classy/block/block.html.twig', Array) (Line: 384)
    Drupal\Core\Theme\ThemeManager->render('block', Array) (Line: 433)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
    Drupal\Core\Render\Renderer->render(Array) (Line: 479)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 54)
    __TwigTemplate_b39e1606fe94231b518d227b2b585037->doDisplay(Array, Array) (Line: 405)
    Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
    Twig\Template->display(Array) (Line: 390)
    Twig\Template->render(Array) (Line: 55)
    twig_render_template('core/modules/layout_builder/layouts/twocol_section/layout--twocol-section.html.twig', Array) (Line: 384)
    Drupal\Core\Theme\ThemeManager->render('layout__twocol_section', Array) (Line: 433)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
    Drupal\Core\Render\Renderer->render(Array, ) (Line: 242)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 243)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
    call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
    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: 49)
    Asm89\Stack\Cors->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)
    

    Also using the BETWEEN exposed filter.
    This seems to only pop up when exposing the operators.

    Can you reproduce it with this information ?

  • Assigned to mohd sahzad
  • Issue was unassigned.
  • 🇮🇳India mohd sahzad

    I'm not reproduce this issue.

  • 🇮🇳India cmak

    Getting same issue on Drupal 9.5.11 with PHP 8.1.20, please see below screenshots attached.

  • 🇳🇱Netherlands Sander Wemagine

    I'm also having the same issue. It occures when exposing the operator.
    It's always happing on my installation, it doesn't matter which theme I use. I have tested on Gin theme and Olivia theme.

  • 🇨🇺Cuba ccolumbie

    I have the same problem with core 10.2.4 and php 8.1.27.

    Warning: Undefined array key "#type" in Drupal\Core\Form\FormHelper::processStates() (line 211 of /var/www/html/core/lib/Drupal/Core/Form/FormHelper.php)

    #0 /var/www/html/core/includes/bootstrap.inc(164): _drupal_error_handler_real(2, 'Undefined array...', '/var/www/html/c...', 211)
    #1 /var/www/html/core/lib/Drupal/Core/Form/FormHelper.php(211): _drupal_error_handler(2, 'Undefined array...', '/var/www/html/c...', 211)
    #2 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(447): Drupal\Core\Form\FormHelper::processStates(Array)
    #3 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(493): Drupal\Core\Render\Renderer->doRender(Array)
    #4 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(493): Drupal\Core\Render\Renderer->doRender(Array)
    #5 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
    #6 /var/www/html/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
    #7 /var/www/html/sites/default/files/php/twig/6622a572537ab_table.html.twig_ikeuxK6Ycwitx_aR_t9weRlES/Oe2pFZrZIwFulnMpsjtykc9ByntX0dqg9YJBA7O0CQo.php(179): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
    #8 /var/www/html/vendor/twig/twig/src/Template.php(394): __TwigTemplate_2f87943cedf7089d68051b4bda7909e4->doDisplay(Array, Array)
    #9 /var/www/html/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
    #10 /var/www/html/vendor/twig/twig/src/Template.php(379): Twig\Template->display(Array)
    #11 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
    #12 /var/www/html/core/themes/engines/twig/twig.engine(39): Twig\TemplateWrapper->render(Array)
    #13 /var/www/html/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('themes/contrib/...', Array)
    #14 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(480): Drupal\Core\Theme\ThemeManager->render('table', Array)
    #15 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
    #16 /var/www/html/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
    #17 /var/www/html/sites/default/files/php/twig/6622a572537ab_field-multiple-value-form__-fBpc5R0_baBczcTTpzZExu8/nHuKHFZqsTpyHoO-g8WhH2ASVtZYOt-c9hXp0vuV00c.php(50): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
    #18 /var/www/html/vendor/twig/twig/src/Template.php(394): __TwigTemplate_9e07f5bab0024d8e59863cb88ad5313b->doDisplay(Array, Array)
    #19 /var/www/html/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
    #20 /var/www/html/vendor/twig/twig/src/Template.php(379): Twig\Template->display(Array)
    #21 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
    #22 /var/www/html/core/themes/engines/twig/twig.engine(39): Twig\TemplateWrapper->render(Array)
    #23 /var/www/html/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('core/modules/sy...', Array)
    #24 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(480): Drupal\Core\Theme\ThemeManager->render('field_multiple_...', Array)
    #25 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(493): Drupal\Core\Render\Renderer->doRender(Array)
    #26 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(493): Drupal\Core\Render\Renderer->doRender(Array)
    #27 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
    #28 /var/www/html/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
    #29 /var/www/html/sites/default/files/php/twig/6622a572537ab_node-edit-form.html.twig__t4CVA_vLT0YbXjC2AiwTdUJL/LgWlhhF15jRMIdiYbVnu3p5tmEaHRt38jKqFvwhA_RA.php(43): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
    #30 /var/www/html/vendor/twig/twig/src/Template.php(394): __TwigTemplate_61251f366ecd789d9923ce1207c62250->doDisplay(Array, Array)
    #31 /var/www/html/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
    #32 /var/www/html/vendor/twig/twig/src/Template.php(379): Twig\Template->display(Array)
    #33 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
    #34 /var/www/html/core/themes/engines/twig/twig.engine(39): Twig\TemplateWrapper->render(Array)
    #35 /var/www/html/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('themes/contrib/...', Array)
    #36 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(480): Drupal\Core\Theme\ThemeManager->render('node_edit_form', Array)
    #37 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
    #38 /var/www/html/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render(Array, false)
    #39 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
    #40 /var/www/html/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(239): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #41 /var/www/html/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
    #42 /var/www/html/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
    #43 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
    #44 /var/www/html/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
    #45 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
    #46 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #47 /var/www/html/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #48 /var/www/html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #49 /var/www/html/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #50 /var/www/html/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #51 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #52 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #53 /var/www/html/vendor/asm89/stack-cors/src/Cors.php(53): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #54 /var/www/html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Asm89\Stack\Cors->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #55 /var/www/html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #56 /var/www/html/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #57 /var/www/html/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #58 /var/www/html/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #59 /var/www/html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #60 {main}

  • 🇺🇸United States redkabbage

    The `#type` has been removed from the `min` and max` form elements. Formerly, they were textfields. Instead of being unset, they should be changed to something like a container or an item. I've included a patch from 1.0.1.

    I'll create a merge request as well.

Production build 0.71.5 2024