Project

General

Profile

Actions

Bug #82554

closed

Backend column with eval datetime and null checkbox not working as expected

Added by Michael Berger about 7 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2017-09-25
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

How to reproduce the bug:
Create a TCA column with eval "datetime" and "null" and a database table column of type "datetime" that is nullable.

Expected behaviour:
When the checkbox is unchecked null will be saved to database as the column value. This works as expected.
When the checkbox is checked and a date is supplied this will be saved to dabase. Working as expected.
But when you edit an item the checkbox will always be checked even if the table column is null. This is because the databaseRow value is "0" but the checkbox checks for "null". Simply put: You edit an item but don't even touch the date fields. Just save it. As the checkbox is checked the database table column will now save a datetime of "0000-00-00 00:00:00" instead of "null".

Fix/Hack:
To fix this for nullable date fields sysext/backend/Classes/Form/FormDataProvider/DatabaseRowDateTimeFields.php can be modified with an additional check for a nullable column.

Quick and dirty example:

...
} else if (empty($result['databaseRow'][$column]) && in_array('null', explode(',', $columnConfig['config']['eval']))) {
    $result['databaseRow'][$column] = null;
} else {
...
Actions

Also available in: Atom PDF