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
DateTimeFieldfor a property whose default value is aDateTimeinstance 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-localandtimetypes, allowing theirvalidity.validproperty to befalseas long as it's only theirvalidity.stepMismatchvalue causing it. - Setting the
stepproperty value to 1 second forDateTimeFieldandTimeFieldinstances whose format includes seconds - Setting the
stepproperty value to 1 second for allDateTimeFieldandTimeFieldinstances - this will be easier than 2. but I wonder if there would be any negative consequences to this