Slug TCA type - Wrong date format initial
The problem is that a date field (inputDateTime) is going to be transformed initially to a wrong date format like 2019-02-04t000000z
I have an entity with two url relevant fields, name and date_of_birth.
The config of both:
'name' => [ 'exclude' => 1, 'label' => 'name', 'config' => [ 'type' => 'input', 'size' => 30, 'eval' => 'trim, required', ], ], 'date_of_birth' => [ 'label' => 'date_of_birth', 'config' => [ 'type' => 'input', 'renderType' => 'inputDateTime', 'eval' => 'date, required', 'default' => 0, 'range' => [ //maximum today 'upper' => mktime(23, 59, 0, date('m'), date('d'), date('Y')), ], ], ],
The output I expect is a simple_ name-xx.xx.xxx_ url segment for this entity.
I have the following config with a slug type:
'path_segment' => [ 'exclude' => true, 'label' => 'path_segment', 'config' => [ 'type' => 'slug', 'size' => 50, 'generatorOptions' => [ 'fields' => ['name', 'date_of_birth'], 'fieldSeparator' => '-', 'prefixParentPageSlug' => true, ], 'fallbackCharacter' => '-', 'eval' => 'uniqueInSite', 'default' => '', ], ],
If I have the following input by creating a new entity:
then the problem is that this configuration results the following by saving the record:
If I click on the "Recalculate URL segment from page title" button it will be fixed as:
It seems that the date conversion does not work correctly initial.
- BE languages is german, website default language is german too.
- I have tested it on the frontend and unfortunately without a refresh the wrong segment will be used. (so the wrong value is saved into the database.)
- Used version: 9.5.4
#1 Updated by Guido Schmechel 5 months ago
I can confirm the problem.
Just a little background:
If we save a entry first, the DataHandler jumps into the function "checkValueForSlug" and generates the slug:
$value = $helper->generate($fullRecord, $realPid);
The content of the $fullRecord variable is the given datetime from the database. Mentioned in the "2018-11-14t000000z" format.
If we use the suggest button. The route slug/suggest is called: sysext/backend/Classes/Controller/FormSlugAjaxController.php->suggestAction() Here we using the transformed $data with TCA Config
which are included in the HTTP Request.
$values = $queryParameters['values'];
Now we have the "correct" datetime format.
The question is: What is the correct place to process the data with TCA config?
The same problem would have to occur with other fields that are further processed by TCA. For example, select fields with a foreign table. Since you would only get the uid and not, for example a title.