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