Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] TimeType request with single_text and without seconds returns seconds #30735

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

Closed
Fahmus opened this issue Mar 27, 2019 · 1 comment
Closed

Comments

@Fahmus
Copy link

Fahmus commented Mar 27, 2019

Symfony version(s) affected: > 2.3

Description
Submitting a TimeType without seconds and with input option set to "string" and
widget option set to "single_text"
Getting value with seconds: H:i:s
How to reproduce

        $builder->add(
            'begin',
            TimeType::class,
            [
                'widget'  => 'single_text',
                'input' => 'string'
            ]
        );

Possible Solution
In https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php#L117
Change H:i:s by $format
new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone'], 'H:i:s')

@Fahmus Fahmus changed the title Form] Date\TimeType marked as invalid on request with single_text and without seconds returns seconds Form] Date\TimeType request with single_text and without seconds returns seconds Mar 27, 2019
@Fahmus Fahmus changed the title Form] Date\TimeType request with single_text and without seconds returns seconds [Form] Date\TimeType request with single_text and without seconds returns seconds Mar 27, 2019
@Fahmus Fahmus changed the title [Form] Date\TimeType request with single_text and without seconds returns seconds [Form] TimeType request with single_text and without seconds returns seconds Mar 27, 2019
@xabbuh
Copy link
Member

xabbuh commented Mar 27, 2019

This will be possible in Symfony 4.3 thanks to the changes made in #30358 and the new input_format option.

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

2 participants