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

[Form] TimeType does not work in new Edge #35989

Closed
jackbentley opened this issue Mar 6, 2020 · 6 comments
Closed

[Form] TimeType does not work in new Edge #35989

jackbentley opened this issue Mar 6, 2020 · 6 comments

Comments

@jackbentley
Copy link

jackbentley commented Mar 6, 2020

Symfony version(s) affected: all

Description
When submitting a form via Edge using the TimeType; Edge will submit the value with both seconds and milliseconds every time regardless of the step attribute (e.g. 20:11:00.000). This is valid according to W3C.

It looks like Symfony is unable to parse the milliseconds in the DateTimeToStringTransformer and this then causes an invalid value.

This only seems to be an issue since Edge has moved to Webkit.

How to reproduce

  1. Create a form with a TimeType
  2. Attempt to submit the form with a value in Edge 80+

Possible Solution

Additional context

@jackbentley jackbentley added the Bug label Mar 6, 2020
@jackbentley jackbentley changed the title [Form [Form] TimeType does not work in new Edge Mar 6, 2020
@xabbuh
Copy link
Member

xabbuh commented Mar 6, 2020

Can you please be a bit more precise? What does "does not work" mean?

@xabbuh xabbuh added the Form label Mar 6, 2020
@jackbentley
Copy link
Author

@xabbuh Apologies, I submitted the bug report before typing the info in. Have updated the description now.

@jackbentley
Copy link
Author

jackbentley commented Mar 6, 2020

My current work around is to add an event listener to strip the parts of the value that aren't expected by the TimeType's $format in the DateTimeToStringTransformer.

The array_slice here only give hours and minutes, as my input doesn't use the with_seconds option.

$builder->get('time')->addEventListener(
    FormEvents::PRE_SUBMIT,
    function (FormEvent $e) {
       $e->setData(
            implode(
                ':',
                array_slice(
                    explode(
                        ':',
                        explode(
                            '.',
                            $e->getData()
                        )[0]
                    ),
                    0,
                    2
                )
            )
        );
    }
);

@xabbuh
Copy link
Member

xabbuh commented Mar 9, 2020

@jackbentley Does that mean that Edge will always submit the value in the 20:11:00.000 format?

@jackbentley
Copy link
Author

@xabbuh Correct. And it looks like the type is expecting hh:mm or hh:mm:ss if you have with_seconds.

@xabbuh
Copy link
Member

xabbuh commented Mar 10, 2020

@jackbentley Can you confirm that #36020 fixes this issue?

nicolas-grekas added a commit that referenced this issue Mar 13, 2020
This PR was merged into the 3.4 branch.

Discussion
----------

[Form] ignore microseconds submitted by Edge

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35989
| License       | MIT
| Doc PR        |

Commits
-------

20971df ignore microseconds submitted by Edge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants