Problem/Motivation

When adding or configuring a timestamp-based date filter (e.g., "Content: Changed") in the Views admin UI, the AJAX dialog fails with the error:

"Oops, something went wrong. Check your browser's developer console for more details."

The browser console shows:

Warning: Undefined array key "#type" in /var/www/docroot/core/modules/views/src/Plugin/views/filter/Date.php on line 42

This PHP warning is output before the AJAX JSON response, corrupting it and preventing JavaScript from parsing it. As a result:

- The "Add and configure filter criteria" dialog either never opens or silently fails
- After page refresh, the filter appears added but clicking it to configure produces the same AJAX error
- The filter becomes completely unconfigurable through the UI

In core/modules/views/src/Plugin/views/filter/Date.php, the valueForm() method at line 42 does:

parent::valueForm($form, $form_state);
if ($form['value']['#type'] === 'textfield') {
    $form['value']['#type'] = 'date';
}

The parent class NumericFilter::valueForm() builds $form['value'] differently depending on context:

- When exposed with a single-value operator (e.g., =, <, >): Sets $form['value']['#type'] = 'textfield'
- In the admin UI or with two-value operators (e.g., between): Creates $form['value'] as a container with child elements (value, min, max) — the container has no #type key

When $form['value'] has no #type key, accessing $form['value']['#type'] triggers a PHP warning. In the context of an AJAX request, this warning text gets prepended to the JSON response, making it unparseable and breaking the entire Views filter dialog.

This regression was introduced by the changes from #2648950 which added the textfield-to-date conversion logic.

Steps to reproduce

1. Go to /admin/structure/views and create or edit any view
2. Under "Filter Criteria", click "Add"
3. Search for and select "Content: Changed" (or any timestamp-based date filter like "Content: Authored on")
4. Check the checkbox and click "Add and configure filter criteria"
5. Result: The dialog fails to open. An error banner appears: "Oops, something went wrong."
6. Open the browser console — you will see the Undefined array key "#type" warning from Date.php line 42 corrupting the AJAX response
7. Refresh the page — the filter now shows as added (e.g., Content: Changed (= ))
8. Click on the filter to configure it — same AJAX error occurs again

This is reproducible on a clean Drupal 10.5.6 installation using any admin theme (Claro, Gin, etc.).

Proposed resolution

Add an isset() check before accessing $form['value']['#type'] in Date::valueForm():

// Before (broken):
if ($form['value']['#type'] === 'textfield') {

// After (fixed):
if (isset($form['value']['#type']) && $form['value']['#type'] === 'textfield') {

This is consistent with how similar undefined key issues have been resolved elsewhere in the Date filter class (see #3294700, #3389478).

Remaining tasks

- Review and commit the attached patch
- Add test coverage (optional follow-up)

User interface changes

None. This fix restores the intended behavior — the Views filter configuration dialog opens correctly via AJAX without errors.

Introduced terminology

N/A

API changes

None.

Data model changes

None.

Release notes snippet

Fixed a bug where adding or configuring timestamp-based date filters (e.g., "Content: Changed", "Content: Authored on") in the Views admin UI would fail with an AJAX error due to an undefined array key "#type" in Date::valueForm(). The filter configuration dialog now opens correctly for all operator types.

Comments

arunkarthick created an issue. See original summary.

quietone’s picture

Version: 10.5.x-dev » main

Hi, Issues for Drupal core should be targeted to the 'main' branch, our primary development branch. Changes are made on the main branch first, and are then back ported as needed according to the Core change policies. The version the problem was discovered on should be stated in the issue summary Problem/Motivation section. Thanks.