bug #36083 [DI][Form] Fixed test suite (TimeType changes & unresolved 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
-------

18f5b17249 [DI][Form] Fixed test suite (TimeType changes & unresolved merge conflict)
This commit is contained in:
Fabien Potencier 2020-03-15 15:10:17 +01:00
commit cc8d23a8ce

View File

@ -60,8 +60,6 @@ class TimeType extends AbstractType
}
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)) {
@ -86,6 +84,8 @@ class TimeType extends AbstractType
}
});
}
$builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format));
} else {
$hourOptions = $minuteOptions = $secondOptions = [
'error_bubbling' => true,