Project

General

Profile

Actions

Bug #99847

closed

Null value for time field is ignored in BE

Added by JAKOTA Design Group GmbH almost 2 years ago. Updated 4 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Start date:
2023-02-06
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.0
Tags:
Complexity:
no-brainer
Is Regression:
Sprint Focus:

Description

Hi,

Following the example for building a time picker

https://docs.typo3.org/m/typo3/reference-tca/11.5/en-us/ColumnsConfig/Type/Input/DateTime/Properties/DbType.html

I've done this:

    'start_time' => [
      'exclude' => true,
      'l10n_mode' => 'exclude',
      'l10n_display' => 'defaultAsReadonly',
      'label' => 'Start time',
      'config' => [
        'type' => 'input',
        'renderType' => 'inputDateTime',
        'dbType' => 'time',
        'size' => 4,
        'disableAgeDisplay' => true,
        'eval' => 'time,null',
        'default' => null,
      ],
    ],
CREATE TABLE tx_myext_domain_model_thing (
  start_time time default NULL,
);

and it work fine.

But if the field value in the DB is null the "Set value" checkbox should not be set automatically.

And another thing even if the checkbox for "Set value" is set and the field value in the backend is 00:00 the value in the DB is not changed from null to 00:00

This makes it hard to determine if no value is set or the time is 00:00.

Thanks


Related issues 4 (1 open3 closed)

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

Actions
Related to TYPO3 Core - Bug #98252: TCA Default value for times cannot be setClosed2022-09-02

Actions
Related to TYPO3 Core - Bug #100649: Extbase DataMapper doesn't respect datetime when 0 or 0000-00-00 or 0000-00-00 00:00:00 or 00:00:00New2023-04-18

Actions
Related to TYPO3 Core - Bug #92900: Unable to store "epoch start" on native datetime fields with dbtypeClosed2020-11-21

Actions
Actions #1

Updated by JAKOTA Design Group GmbH almost 2 years ago

One additional note:

The value is only not saved as 00:00 and left null if 00:00 is put in the input field.
If the TimePicker UI is used to set the value the time 00:00 is saved to DB.

Actions #2

Updated by JAKOTA Design Group GmbH almost 2 years ago

  • Complexity set to no-brainer

I've found the reason why this is not working.

/typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseRowDateTimeFields.php

always sets the value to 0 if it is null and also is not returning the correct timestamp for 00:00.

Line: 49 to 51 is:

                } else {
                    $result['databaseRow'][$column] = $format['reset'] ?? null;
                }

but should/could be:

                } else if ($result['databaseRow'][$column] === ($format['empty'] ?? null)) {
                    $result['databaseRow'][$column] = date('c', 0);
                } else if (null !== $result['databaseRow'][$column]) {
                    $result['databaseRow'][$column] = ($format['reset'] ?? null) === null ? null : date('c', (int)$format['reset']);
                }

This solves both issues.

I'm not sure why the first "if" checks for an format empty

&& $result['databaseRow'][$column] !== ($format['empty'] ?? null)

Cause even that needs to be converted to something like 1970-01-01T00:00:00+00:00 otherwise this value gets set back to null the next time the record is saved.

If someone could have a look please.

Thanks.

Actions #3

Updated by Gerrit Code Review over 1 year ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #4

Updated by Gerrit Code Review over 1 year ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #5

Updated by Gerrit Code Review over 1 year ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #6

Updated by Gerrit Code Review over 1 year ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #7

Updated by Gerrit Code Review over 1 year ago

Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #8

Updated by Gerrit Code Review over 1 year ago

Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #9

Updated by Gerrit Code Review over 1 year ago

Patch set 7 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #10

Updated by JAKOTA Design Group GmbH over 1 year ago

  • Related to Bug #97216: Time value "midnight" (00:00) is not accepted added
  • Related to Bug #98252: TCA Default value for times cannot be set added
Actions #11

Updated by Gerrit Code Review over 1 year ago

Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78168

Actions #12

Updated by Gerrit Code Review over 1 year ago

Patch set 8 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #13

Updated by Gerrit Code Review over 1 year ago

Patch set 9 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #14

Updated by Sebastien Convers over 1 year ago

  • Related to Bug #100649: Extbase DataMapper doesn't respect datetime when 0 or 0000-00-00 or 0000-00-00 00:00:00 or 00:00:00 added
Actions #15

Updated by JAKOTA Design Group GmbH over 1 year ago

  • Related to Bug #92900: Unable to store "epoch start" on native datetime fields with dbtype added
Actions #16

Updated by Gerrit Code Review over 1 year ago

Patch set 2 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78168

Actions #17

Updated by Gerrit Code Review over 1 year ago

Patch set 10 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #18

Updated by Gerrit Code Review over 1 year ago

Patch set 11 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #19

Updated by Gerrit Code Review over 1 year ago

Patch set 12 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #20

Updated by Gerrit Code Review over 1 year ago

Patch set 13 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #21

Updated by Gerrit Code Review over 1 year ago

Patch set 14 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #22

Updated by Gerrit Code Review over 1 year ago

Patch set 15 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78096

Actions #23

Updated by Gerrit Code Review over 1 year ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/79748

Actions #24

Updated by Gerrit Code Review over 1 year ago

Patch set 3 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78168

Actions #25

Updated by Gerrit Code Review over 1 year ago

Patch set 4 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78168

Actions #26

Updated by JAKOTA Design Group GmbH over 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #27

Updated by Gerrit Code Review over 1 year ago

  • Status changed from Resolved to Under Review

Patch set 5 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78168

Actions #28

Updated by Gerrit Code Review over 1 year ago

Patch set 6 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78168

Actions #29

Updated by Gerrit Code Review over 1 year ago

Patch set 7 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78168

Actions #30

Updated by Gerrit Code Review over 1 year ago

Patch set 8 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78168

Actions #31

Updated by Gerrit Code Review over 1 year ago

Patch set 9 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78168

Actions #32

Updated by JAKOTA Design Group GmbH over 1 year ago

  • Status changed from Under Review to Resolved
Actions #33

Updated by Benni Mack 4 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF