Project

General

Profile

Actions

Feature #106681

open

Allow relative dates in DateRangeValidator (and default value)

Added by Uwe Wiebach about 1 month ago. Updated 13 days ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2025-05-12
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

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.

Actions #1

Updated by Georg Ringer about 1 month ago

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

Actions #2

Updated by Gerrit Code Review 13 days 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/+/89665

Actions #3

Updated by Uwe Wiebach 13 days ago

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

Actions #4

Updated by Gerrit Code Review 13 days 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/+/89665

Actions

Also available in: Atom PDF