Closed lekoala closed 1 month ago
Still work in progress
the basic idea would be to add some kind of common helper
private function expandValue(?string $value, IntlDateFormatter $formatter): int|false
{
$zeroFormat = $formatter->format(strtotime(date('Y-01-01 00:00:00')));
$expectedLength = strlen($zeroFormat);
if (strlen($value) >= $expectedLength) {
return false;
}
$expandedValue = $value . substr($zeroFormat, strlen($value));
return $formatter->parse($expandedValue);
}
i realize that there are many cases where you can setValue, setSubmittedValue, convert from frontend to internal, tidy internals, ... it's not always super consistent and basically i'd like partial values to work everywhere without too much issues
@lekoala Are you still keen to work on this? It seems like it'd be a really useful feature.
I'm going to close this for now as there hasn't been any action for a few months. Feel free to open a new PR once this is ready for review.
Description
Currently, partial values in date/time field will results in null values. This is a bit annoying for time value (input 18:--:-- will be null) but is even more obvious on datetime field (inputing the date without the time results in null)
Manual testing steps
Only input partial values, it still submit properly
Issues
Pull request checklist