Bug #81548

TCA empty input with renderType => inputDateTime with dbType => date gives error on save

Added by Marieke de Bruin over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2017-06-12
Due date:
% Done:

0%

TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

When I save a not filled (empty) date, I get the following error in CMS 8.7

1: These fields of record 1 in table "tx_my_ext" have not been saved correctly: birthdate! The values might have changed due to type casting of the database.

I have an extension with the following TCA

      'birthdate' => [
            'exclude' => 1,
            'label' => $labelReferencePrefix . 'tx_my_ext.birthdate',
            'config' => [
                'renderType' => 'inputDateTime',
                'dbType' => 'date',
                'type' => 'input',
                'size' => 7,
                'eval' => 'date',
                'checkbox' => 0,
                'default' => '0000-00-00'
            ],
        ],

and the following sql declaration in the ext_tables.sql

birthdate date DEFAULT '0000-00-00',

When I change the table to varchar, the date is saved as 0 while empty

I think the problem is in the 'eval' => 'date' according to the documentation

The field will evaluate the input as a date, automatically converting the input to a UNIX-time in seconds.

But this is only a problem when the value is empty, when it's filled there is no problem.
I can't remove the eval because this is required when you set 'renderType' => 'inputDateTime'


Related issues

Duplicates TYPO3 Core - Bug #79304: SQL error if empty datetime value is saved Closed 2017-01-12

History

#1 Updated by Markus Klein over 2 years ago

  • Parent task set to #77562

#2 Updated by Markus Klein over 2 years ago

  • Status changed from New to Closed

This is fixed with #79304

#3 Updated by Markus Klein over 2 years ago

  • Duplicates Bug #79304: SQL error if empty datetime value is saved added

#4 Updated by Markus Klein over 2 years ago

  • Parent task deleted (#77562)

Also available in: Atom PDF