Issue Feature Closed

#106681Allow relative dates in DateRangeValidator (and default value)

Uwe Wiebach 05/12/25, 13:30 updated 03/31/26, 09:00

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

  1. Georg Ringer commented 05/19/25, 18:29

    hey!
    please still create the patch, especially if you already looked into it!

  2. Gerrit Code Review pushed patch set 1 for main to change 89665 status New Under Review 06/06/25, 16:17

  3. 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…

  4. Gerrit Code Review pushed patch set 2 for main to change 89665 06/06/25, 20:49

  5. Gerrit Code Review pushed patch set 3 for main to change 89665 06/25/25, 11:07

  6. 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.

  7. Garvin Hicking commented 02/25/26, 14:54

    This would be coolX I’d be on board :)

  8. 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.

  9. Gerrit Code Review pushed patch set 5 for main to change 92994 02/26/26, 10:28

  10. Gerrit Code Review pushed patch set 6 for main to change 92994 03/01/26, 12:33

  11. Gerrit Code Review pushed patch set 7 for main to change 92994 03/02/26, 12:52

  12. Gerrit Code Review pushed patch set 8 for main to change 92994 03/02/26, 13:00

  13. Gerrit Code Review pushed patch set 9 for main to change 92994 03/02/26, 16:34

  14. Gerrit Code Review pushed patch set 10 for main to change 92994 03/02/26, 16:36

  15. Josua Vogel commented and changed status Under Review Resolved done 0 % 100 % 03/02/26, 20:35

    Applied in changeset commit:c58f5db24d1bae57f3ed1ad25640a6aee66ca6dd.

  16. Benni Mack changed status Resolved Closed 03/31/26, 09:00