Skip to content

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

@Fahmus

Description

@Fahmus

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')

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions