Issue Bug Closed

#104894legacyHiddenField for Datetime Picker do not work

Christian Dorka 09/11/24, 08:45 updated 03/23/25, 21:51

Description

After updating, to 12.4.19 we got problems that Forms with datepicker in Backend modules do not work.
I am using the FormDataCompiler for that which uses hidden fields.

I got following JS error:
“The hidden field for “@typo3/backend/date-time-picker.js” shall not be used. Please remove this field and supply the ISO8601 date in the user-facing field instead.”

According to the typescript variable naming it´s the legacy hidden field “const legacyHiddenField” (File: Build/Sources/TypeScript/backend/date-time-picker.ts)

But its build via the new date configuration: https://docs.typo3.org/m/typo3/reference-tca/12.4/en-us/ColumnsConfig/Type/Datetime/Index.html#columns-datetime-migration

My code:

$GLOBALS['TCA']['tx_cpcsvexport_filter']['columns']['from'] = [
    'label' => 'Date from ',
    'config' => [
        'type' => 'datetime',
        'format' => 'date'
    ]
];

Problem is, that “onChange” the hidden input field do not get the value change of the datepicker, but an input field without the [name] attribute gets the value, via POST. So no value is submitted on sending (see screenshot in the files).

Following change fixes the error on my side:
=> const legacyHiddenField = inputElement.closest(‘typo3-formengine-element-datetime’) ? null : inputElement.parentElement.parentElement.querySelector(‘input[type=“hidden”]’) as HTMLInputElement;
to
=> const legacyHiddenField = inputElement.closest(‘typo3-formengine-element-datetime’) ? inputElement.parentElement.parentElement.querySelector(‘input[type=“hidden”]’) as HTMLInputElement : null;

Commit that causes this problem https://github.com/TYPO3/typo3/commit/2eedd4585d1c52170409c01e9bcf30484630a858

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.