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

Use HTML datetime-local input with DateTimeField #748

Open
JacobsThierry opened this issue Jul 8, 2022 · 2 comments
Open

Use HTML datetime-local input with DateTimeField #748

JacobsThierry opened this issue Jul 8, 2022 · 2 comments

Comments

@JacobsThierry
Copy link

When using DateTimeField and rendering a template, the html tag generated look like this :

The type is "datetime" which does not mean anything in vanilla HTML. So the browser display the field as a text Field.
The type should be "datetime-local"

Tested with WTforms 3.0.1

@JacobsThierry JacobsThierry changed the title DateTimeField uses a invlalid html-5 type DateTimeField uses a invalid html-5 type Jul 8, 2022
@pibesdesistemas
Copy link

pibesdesistemas commented Aug 19, 2022

In the widgets is define DateTimeLocalField

class DateTimeLocalField(DateTimeField):
    """
    Same as :class:`~wtforms.fields.DateTimeField`, but represents an
    ``<input type="datetime-local">``.
    """

    widget = widgets.DateTimeLocalInput()

    def __init__(self, *args, **kwargs):
        kwargs.setdefault("format", ["%Y-%m-%d %H:%M:%S", "%Y-%m-%dT%H:%M:%S"])
        super().__init__(*args, **kwargs)

@azmeuk
Copy link
Member

azmeuk commented Jan 13, 2023

Indeed it seems that <input type="datetime"> is now obsolete. I don't know if we should remove the field in wtforms, or if we should keep it for some compatibility reasons.

@azmeuk azmeuk changed the title DateTimeField uses a invalid html-5 type Use HTML datetime-local input with DateTimeField Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants