EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Unable to submit form with DateTimeField whose value contains seconds in Safari

Open andyexeter opened this issue 2 years ago • 0 comments

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 a DateTime 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:

  1. In the form.js validation by adding special logic for datetime, datetime-local and time types, allowing their validity.valid property to be false as long as it's only their validity.stepMismatch value causing it.
  2. Setting the step property value to 1 second for DateTimeField and TimeField instances whose format includes seconds
  3. Setting the step property value to 1 second for all DateTimeField and TimeField instances - this will be easier than 2. but I wonder if there would be any negative consequences to this

andyexeter avatar Jun 22 '22 12:06 andyexeter