Skip to content

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

@dootix-developer

Description

@dootix-developer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions