laminas / laminas-form

Validate and display simple and complex forms, casting forms to business objects and vice versa
https://docs.laminas.dev/laminas-form/
BSD 3-Clause "New" or "Revised" License
80 stars 52 forks source link

DateTimeLocal considers the "step" attribute to be minutes, when the HTML element specification asserts that it is seconds #265

Open dootix-developer opened 9 months ago

dootix-developer commented 9 months ago

Bug Report

Q A
Version(s) 2.0.4 → 3.20.x

Summary

The DateStepValidator created by DateTime uses the "step" attribute as if it were minutes, while the HTML input of type "datetime-local," considers it to be seconds. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local#step So, in most cases, you get a validation error, either from the browser side or from the PHP side.

Current behavior

For example, let's imagine that we want to restrict the selection to multiples of 30 minutes: if we set the "step" attribute to 1800, following the HTML standard, the input works correctly, but the DateStepValidator returns an error (for all values that do not respect a 30-hour step); if we set the "step" attribute to 30, the DateStepValidator works correctly (though contrary to the HTML specification), but the input allows incorrect values and, in most browsers, includes the selection of seconds.

How to reproduce

Create a Laminas Form, add a DateTimeLocal element and set the "step" attribute to any value. The browser will accept the input value if you consider "step" to be in seconds, and the PHP-side validation will accept the input if you consider "step" to be in minutes.

Expected behavior

DateTimeLocal should create a DateStepValidator that complies with the HTML standard, that is, it considers the value of the "step" attribute as seconds. The validation on the browser side and the validation provided by Laminas Validator should match.

devlubinets commented 8 months ago

Interesting