|
23 | 23 | use Symfony\Component\Form\FormView; |
24 | 24 | use Symfony\Component\Form\ReversedTransformer; |
25 | 25 | use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; |
26 | | -use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; |
27 | 26 | use Symfony\Component\OptionsResolver\Options; |
28 | 27 | use Symfony\Component\OptionsResolver\OptionsResolver; |
29 | 28 |
|
@@ -324,23 +323,13 @@ public function configureOptions(OptionsResolver $resolver) |
324 | 323 | $resolver->setAllowedTypes('days', 'array'); |
325 | 324 | $resolver->setAllowedTypes('input_format', 'string'); |
326 | 325 |
|
327 | | - foreach (['html5', 'widget', 'format'] as $option) { |
328 | | - $resolver->setDeprecated($option, static function (Options $options, $value) use ($option): string { |
329 | | - try { |
330 | | - $html5 = 'html5' === $option ? $value : $options['html5']; |
331 | | - $widget = 'widget' === $option ? $value : $options['widget']; |
332 | | - $format = 'format' === $option ? $value : $options['format']; |
333 | | - } catch (OptionDefinitionException $e) { |
334 | | - return ''; |
335 | | - } |
336 | | - |
337 | | - if ($html5 && 'single_text' === $widget && self::HTML5_FORMAT !== $format) { |
338 | | - throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class)); |
339 | | - } |
| 326 | + $resolver->setNormalizer('html5', function (Options $options, $html5) { |
| 327 | + if ($html5 && 'single_text' === $options['widget'] && self::HTML5_FORMAT !== $options['format']) { |
| 328 | + throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is enabled.', self::class)); |
| 329 | + } |
340 | 330 |
|
341 | | - return $html5; |
342 | | - }); |
343 | | - } |
| 331 | + return $html5; |
| 332 | + }); |
344 | 333 | } |
345 | 334 |
|
346 | 335 | /** |
|
0 commit comments