Skip to content

Commit

Permalink
minor #30230 [Form] undeprecate date formats in single_text widgets (…
Browse files Browse the repository at this point in the history
…xabbuh)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[Form] undeprecate date formats in single_text widgets

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

1a983d0 undeprecate date formats in single_text widgets
  • Loading branch information
xabbuh committed Feb 20, 2019
2 parents ccd4bbe + 1a983d0 commit c3cf08e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Expand Up @@ -294,9 +294,9 @@ public function configureOptions(OptionsResolver $resolver)
]); ]);


$resolver->setDeprecated('date_format', function (Options $options, $dateFormat) { $resolver->setDeprecated('date_format', function (Options $options, $dateFormat) {
if (null !== $dateFormat && 'single_text' === $options['widget']) { if (null !== $dateFormat && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) {
return sprintf('Using the "date_format" option of %s when the "widget" option is set to "single_text" is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class); return sprintf('Using the "date_format" option of %s with an HTML5 date widget is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class);
//throw new LogicException(sprintf('Cannot use the "date_format" option of the %s when the "widget" option is set to "single_text".', self::class)); //throw new LogicException(sprintf('Cannot use the "date_format" option of the %s with an HTML5 date.', self::class));
} }


return ''; return '';
Expand Down
Expand Up @@ -491,6 +491,18 @@ public function testDontPassHtml5TypeIfNotSingleText()
$this->assertArrayNotHasKey('type', $view->vars); $this->assertArrayNotHasKey('type', $view->vars);
} }


public function testSingleTextWidgetWithCustomNonHtml5Format()
{
$form = $this->factory->create(static::TESTED_TYPE, new \DateTime('2019-02-13 19:12:13'), [
'widget' => 'single_text',
'date_format' => \IntlDateFormatter::SHORT,
'format' => null,
]);
$view = $form->createView();

$this->assertSame('2/13/19, 7:12:13 PM', $view->vars['value']);
}

public function testDateTypeChoiceErrorsBubbleUp() public function testDateTypeChoiceErrorsBubbleUp()
{ {
$error = new FormError('Invalid!'); $error = new FormError('Invalid!');
Expand Down

0 comments on commit c3cf08e

Please sign in to comment.