Bug #82554
closedBackend column with eval datetime and null checkbox not working as expected
0%
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 {
...
Updated by Susanne Moog over 4 years ago
- Status changed from New to Closed
Is working in current TYPO3 versions:
TCA:
'inputdatetime_11' => [ 'exclude' => 1, 'label' => 'inputdatetime_4 dbType=datetime eval=datetime null', 'config' => [ 'type' => 'input', 'renderType' => 'inputDateTime', 'dbType' => 'datetime', 'eval' => 'datetime,null', ], ],
ext_tables.sql:
inputdatetime_11 datetime,
Steps to test:
- Open record, set a date => saves the date
- Open record, uncheck checkbox => checkbox stays unchecked after saving
- Open record with unchecked checkbox, edit different field (the case the issue describes) => checkbox stays unchecked after saving