Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dootix-developer opened this issue Jan 30, 2024 · 1 comment
Labels
Bug Something isn't working

Comments

@dootix-developer
Copy link

dootix-developer commented Jan 30, 2024

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.

@dootix-developer dootix-developer added the Bug Something isn't working label Jan 30, 2024
@devlubinets
Copy link

Interesting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants