EasyAdminBundle
EasyAdminBundle copied to clipboard
Unable to submit form with DateTimeField whose value contains seconds in Safari
Describe the bug
When a DateTimeField
's value contains non-zero seconds (e.g. 2022-06-22 10:00:13), a form cannot be submitted in Safari because of the input.validity.valid
check here:
https://github.com/EasyCorp/EasyAdminBundle/blob/6fb878eaab2a5863fe8996fccab83658bd7d1113/assets/js/form.js#L67-L69
validity.valid
is false
on the datetime input because validity.stepMismatch
is true
- this is because the default step
property value is 60 seconds and current seconds value is 13.
Changing the time to 10:00:00 passes validation and allows the form to be submitted.
To Reproduce
- Add to a form a
DateTimeField
for a property whose default value is aDateTime
instance with a non-zero seconds value - Attempt to save the form in Safari
I am happy to create a PR to fix this, but I see a few different ways this can be fixed:
- In the form.js validation by adding special logic for
datetime
,datetime-local
andtime
types, allowing theirvalidity.valid
property to befalse
as long as it's only theirvalidity.stepMismatch
value causing it. - Setting the
step
property value to 1 second forDateTimeField
andTimeField
instances whose format includes seconds - Setting the
step
property value to 1 second for allDateTimeField
andTimeField
instances - this will be easier than 2. but I wonder if there would be any negative consequences to this