Project

General

Profile

Actions

Bug #89112

closed

TCA: Default date/time and range cannot be set dynamically anymore

Added by Xavier Perseguers over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2019-09-09
Due date:
% Done:

0%

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

Description

We have examples in the documentation on how to set dynamic defaults and allowed range for a date field. Here is TYPO3 7.6 for instance (https://docs.typo3.org/m/typo3/reference-tca/7.6/en-us/Reference/Columns/Input/Index.html):

In this example the upper limit is set to the last day in year 2020 while the lowest possible value is set to the date of yesterday:

'range' => array(
   'upper' => mktime(0, 0, 0, 12, 31, 2020),
   'lower' => mktime(0,0,0,date('m'), date('d'), date('Y'))
)

This does not work anymore since the TCA is now [since v7] cached. Here is a real-world example:

        'start_date' => [
            'exclude' => 0,
            'label' => 'LLL:EXT:myext/Resources/Private/Language/locallang_db.xlf:tx_myext_domain_model_status.start_date',
            'config' => [
                'type' => 'input',
                'size' => 11,
                'max' => 11,
                'eval' => 'date',
                'checkbox' => 1,
                'default' => mktime(0, 0, 0, date('m'), date('d'), date('Y')),
                'range' => [
                    'upper' => mktime(23, 59, 59, date('m'), date('d'), date('Y')) + 12 * 7 * 86400,    // up to 12 weeks in future
                ],
            ],
        ],

And here is the actual configuration using Backend module System > Configuration > TCA:

As you see, the actual TCA values are those when the system cache was last flushed, and it is not dynamic anymore.

It looks like this problem has been silently forgotten as the documentation starting from TYPO3 v8 (https://docs.typo3.org/m/typo3/reference-tca/8.7/en-us/ColumnsConfig/Type/Input.html) does not show a dynamic value anymore:

In this example the upper limit is set to the last day in year 2020 while the lowest possible value is set to the date of 2014:

'range' => [
    'upper' => mktime(0, 0, 0, 12, 31, 2020),
    'lower' => mktime(0, 0, 0, 1, 1, 2014),
],

Question: apart from regularly flushing the system cache (this is what I do on much bigger instance because I deploy regularly and explains why I never figured out this problem before!), what is the official way of achieving this behaviour as up to TYPO3 v6?


Files

configuration.png (26.7 KB) configuration.png Xavier Perseguers, 2019-09-09 08:11
Actions #1

Updated by Georg Ringer over 4 years ago

Hey!

The best way is something like that: https://github.com/georgringer/news/blob/master/Classes/Backend/FormDataProvider/NewsRowInitializeNew.php
this is also far more powerful as you can just do anything

Actions

Also available in: Atom PDF