#106681Allow relative dates in DateRangeValidator (and default value)
Description
I suggest also allowing relative date formats for the date fields in the form editor (DateRangeValidator and maybe also default value). This would make it possible, for example, to ensure that a date of birth can never have a value in the future or must be at least 18 years in the past. At the moment it is only possible to set an absolute date in the format Y-m-d.
The changes for the validator in PHP are IMHO quite simple. Just replace e.g. $minimum = \DateTime::createFromFormat($this->options['format'], $this->options['minimum']); with $minimum = date_create($this->options['minimum']);. Then the beforeRendering hook must be extended so that the attributes “min” and/or “max” are correctly filled. I already got these changes working in my dev setup. What I am still missing, however, is the adaptation of the propertyValidator. Currently, I have simply removed the existing one (“RFC3339FullDateOrEmpty”) to make it work…
I also didn’t have a look at required changes for the default value, as we don’t need relative formats there at the moment…
If you think this could be a useful addition, I could create a patch with my changes up to now.
Reviews 2
Files 1
History 716
-
Georg Ringer commented 05/19/25, 18:29
-
Gerrit Code Review pushed patch set 1 for main to change 89665 status
NewUnder Review 06/06/25, 16:17 -
Uwe Wiebach commented 06/06/25, 16:22
Georg Ringer wrote in #note-1:
> hey!
> please still create the patch, especially if you already looked into it!Here you go. That’s what I’ve got so far…
-
Gerrit Code Review pushed patch set 2 for main to change 89665 06/06/25, 20:49
-
Gerrit Code Review pushed patch set 3 for main to change 89665 06/25/25, 11:07
-
Josua Vogel commented and changed attached Bildschirmfoto 2026-02-25 um 14.13.03.png 02/25/26, 13:17
Hi,
I have provided a customized version: https://review.typo3.org/c/Packages/TYPO3.CMS/+/92994 . During implementation, I wondered whether entering relative values could be made easier. Many editors are certainly not familiar with the PHP expressions :)
A new editor could be built. Before I continue with the project, I would first like some feedback on whether it is worth continuing to work on it.
-> Please see the attached image. -
Garvin Hicking commented 02/25/26, 14:54
This would be coolX I’d be on board :)
-
Uwe Wiebach commented 02/25/26, 15:12
Seems to be a much better solution in terms of user-friendliness than what I’ve managed to achieve so far. I’d say keep up the good work.
-
Gerrit Code Review pushed patch set 5 for main to change 92994 02/26/26, 10:28
-
Gerrit Code Review pushed patch set 6 for main to change 92994 03/01/26, 12:33
-
Gerrit Code Review pushed patch set 7 for main to change 92994 03/02/26, 12:52
-
Gerrit Code Review pushed patch set 8 for main to change 92994 03/02/26, 13:00
-
Gerrit Code Review pushed patch set 9 for main to change 92994 03/02/26, 16:34
-
Gerrit Code Review pushed patch set 10 for main to change 92994 03/02/26, 16:36
-
Josua Vogel commented and changed status
Under ReviewResolved done0 %100 % 03/02/26, 20:35Applied in changeset commit:c58f5db24d1bae57f3ed1ad25640a6aee66ca6dd.
-
Benni Mack changed status
ResolvedClosed 03/31/26, 09:00
hey!
please still create the patch, especially if you already looked into it!