Project

General

Profile

Actions

Bug #98252

open

TCA Default value for times cannot be set

Added by C. Gogolin over 1 year ago. Updated 12 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Start date:
2022-09-02
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
7.4
Tags:
Complexity:
medium
Is Regression:
Sprint Focus:

Description

Hi,

In my extension I have created a table which contains a time field. Under Typo3 10.x everything was fine. But when I switched to Typo3 11, the default value was no longer displayed.

Here is the table.sql:

#
# Table structure for table 'tx_participants_domain_model_event' 
# 
CREATE TABLE tx_participants_domain_model_event (
   uid int(11) UNSIGNED DEFAULT '0' NOT NULL auto_increment,
   pid int(11) DEFAULT '0' NOT NULL,
   ,..
   time VARCHAR(10) DEFAULT '19:00:00' NOT NULL,    
   ...
   PRIMARY KEY (uid),
   KEY parent (pid)
);

Here is the TCA configuration: (works for Typo3 10 , but not for Typo3 11)

'time' => [
            'label' => 'LLL:EXT:participants/Resources/Private/Language/locallang_db.xlf:tx_participants_domain_model_event.time',
            'config' => [
                'type' => 'input',
                'renderType' => 'inputDateTime',
                'dbType' => 'time',
                'eval' => 'time',
                'default' => 68400, // 19:00h
                'mode' => 'useOrOverridePlaceholder'
            ]
        ],

Then I did some searching in the core code and found:
./sysext/core/Classes/Database/Query/QueryHelper.php

The method getDateTimeFormats() does not set the reset to zero but 0 for the type "time".

  /**
     * Returns the date and time formats compatible with the given database.
     *
     * This simple method should probably be deprecated and removed later.
     *
     * @return array
     */
    public static function getDateTimeFormats()
    {
        return [
            'date' => [
                'empty' => '0000-00-00',
                'format' => 'Y-m-d',
                'reset' => null,
            ],
            'datetime' => [
                'empty' => '0000-00-00 00:00:00',
                'format' => 'Y-m-d H:i:s',
                'reset' => null,
            ],
            'time' => [
                'empty' => '00:00:00',
                'format' => 'H:i:s',
                'reset' => 0,
            ],
        ];
    }

This has the consequence that a few steps later my default value is not used. (The fact that I have to patch core again and again can't be a solution ;-) )
Unfortunately I can't understand why a 0 and not (as with "date" and "datetime") zero is specified here. But if I patch the QueryHelper and change 0 to zero, we can use the defaults again.

It would be nice if this is fixed in a timely manner. (Or does this all have to be solved completely different?).

Thanks
Clemens


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #97216: Time value "midnight" (00:00) is not acceptedClosed2022-03-21

Actions
Related to TYPO3 Core - Bug #99847: Null value for time field is ignored in BEResolved2023-02-06

Actions
Actions

Also available in: Atom PDF