Skip to content

Commit

Permalink
bug #36083 [DI][Form] Fixed test suite (TimeType changes & unresolved…
Browse files Browse the repository at this point in the history
… merge conflict) (wouterj)

This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[DI][Form] Fixed test suite (TimeType changes & unresolved merge conflict)

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

After the merge of #36020 , the `addViewTransformer()` was moved to the top of the statement. This is wrong, as the `$format` variable is changed when a `reference_date` is set (see line 77). This broke Symfony's testsuite :)

Commits
-------

18f5b17 [DI][Form] Fixed test suite (TimeType changes & unresolved merge conflict)
  • Loading branch information
fabpot committed Mar 15, 2020
2 parents 31fe1ef + 18f5b17 commit cc8d23a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/Extension/Core/Type/TimeType.php
Expand Up @@ -60,8 +60,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

if ('single_text' === $options['widget']) {
$builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format));

$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $e) use ($options) {
$data = $e->getData();
if ($data && preg_match('/^(?P<hours>\d{2}):(?P<minutes>\d{2})(?::(?P<seconds>\d{2})(?:\.\d+)?)?$/', $data, $matches)) {
Expand All @@ -86,6 +84,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}
});
}

$builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format));
} else {
$hourOptions = $minuteOptions = $secondOptions = [
'error_bubbling' => true,
Expand Down

0 comments on commit cc8d23a

Please sign in to comment.