Feature: #97232 - New TCA type "datetime"

See forge#97232

Description

Especially TCA type input has a wide range of use cases, depending on the configured renderType and the eval options. Determination of the semantic meaning is therefore usually quite hard and often leads to duplicated checks and evaluations in custom extension code.

In our effort of introducing dedicated TCA types for all those use cases, the TCA type datetime has been introduced. It replaces the renderType=inputDateTime of TCA type input.

The TCA type datetime features the following column configuration:

  • behaviour: allowLanguageSynchronization

  • dbType: date, time, datetime

  • default

  • disableAgeDisplay

  • fieldControl

  • fieldInformation

  • fieldWizard

  • format: datetime (default), date, time, timesec

  • mode

  • nullable

  • placeholder

  • range: lower, upper

  • readOnly

  • required

  • search

  • size

Note

The eval=int option is now automatically set for the element in case no specific dbType has been defined. It should therefore be removed from the TCA configuration.

Note

The format option defines how the display of the field value will be in e.g. FormEngine. The storage format is defined via dbType or eval=int.

The following column configuration can be overwritten by Page TSconfig:

  • readOnly

  • size

A complete migration from renderType=inputDateTime to type=datetime looks like the following:

 // Before

 'a_datetime_field' => [
     'label' => 'Datetime field',
     'config' => [
         'type' => 'input',
         'renderType' => 'inputDateTime',
         'required' => true,
         'size' => 20,
         'max' => 1024,
         'eval' => 'date,int',
         'default' => 0,
     ],
 ],

// After

 'a_datetime_field' => [
     'label' => 'Datetime field',
     'config' => [
         'type' => 'datetime',
         'format' => 'date',
         'required' => true,
         'size' => 20,
         'default' => 0,
     ]
 ]

An automatic TCA migration is performed on the fly, migrating all occurrences to the new TCA type and triggering a PHP E_USER_DEPRECATED error where code adoption has to take place.

Note

The corresponding FormEngine class has been renamed from InputDateTimeElement to DatetimeElement. An entry in the "ClassAliasMap" has been added for extensions calling this class directly, which is rather unlikely. The extension scanner will report any usage, which should then be migrated.

Automatic database fields

TYPO3 automatically creates database fields for TCA type datetime columns, if they have not already been defined in an extensions' ext_tables.sql file. This also supports columns, having a native database type (dbType) defined. Fields without a native type do always define default 0 and are always signed (to allow negative timestamps). As long as a column does not use nullable=true, the fields are also always defined as NOT NULL.

Impact

It's now possible to simplify the TCA configuration by using the new dedicated TCA type datetime. Next to reduced TCA configuration does the new type allow to omit the corresponding database field definition.