Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c1bc7a2

Browse filesBrowse files
committed
deprecate some options for single_text widgets
1 parent d482f0a commit c1bc7a2
Copy full SHA for c1bc7a2

File tree

6 files changed

+39
-2
lines changed
Filter options

6 files changed

+39
-2
lines changed

‎UPGRADE-4.2.md

Copy file name to clipboardExpand all lines: UPGRADE-4.2.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Finder
5555
Form
5656
----
5757

58+
* Using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget` option is
59+
set to `single_text` is deprecated.
5860
* The `scale` option of the `IntegerType` is deprecated.
5961
* The `$scale` argument of the `IntegerToLocalizedStringTransformer` is deprecated.
6062

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ Finder
7272
Form
7373
----
7474

75+
* Using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget` option is
76+
set to `single_text` is not supported anymore.
7577
* The `scale` option was removed from the `IntegerType`.
7678
* The `$scale` argument of the `IntegerToLocalizedStringTransformer` was removed.
7779

‎src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,9 @@ public function testDateTimeWithWidgetSingleText()
15821582
);
15831583
}
15841584

1585+
/**
1586+
* @group legacy
1587+
*/
15851588
public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets()
15861589
{
15871590
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(

‎src/Symfony/Component/Form/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGELOG
44
4.2.0
55
-----
66

7+
* deprecated using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget`
8+
option is set to `single_text`
79
* deprecated the `$scale` argument of the `IntegerToLocalizedStringTransformer`
810
* added `Symfony\Component\Form\ClearableErrorsInterface`
911
* deprecated calling `FormRenderer::searchAndRenderBlock` for fields which were already rendered

‎src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php
+27-2Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ public function configureOptions(OptionsResolver $resolver)
205205

206206
// Defaults to the value of "widget"
207207
$dateWidget = function (Options $options) {
208-
return $options['widget'];
208+
return 'single_text' === $options['widget'] ? null : $options['widget'];
209209
};
210210

211211
// Defaults to the value of "widget"
212212
$timeWidget = function (Options $options) {
213-
return $options['widget'];
213+
return 'single_text' === $options['widget'] ? null : $options['widget'];
214214
};
215215

216216
$resolver->setDefaults(array(
@@ -278,6 +278,31 @@ public function configureOptions(OptionsResolver $resolver)
278278
'text',
279279
'choice',
280280
));
281+
282+
$resolver->setNormalizer('date_format', function (Options $options, $dateFormat) {
283+
if (null !== $dateFormat && 'single_text' === $options['widget']) {
284+
@trigger_error(sprintf('Using the "date_format" option of the %s when the "widget" option is set to "single_text" is deprecated since Symfony 4.2 and will lead to an exception in 5.0.', self::class), E_USER_DEPRECATED);
285+
//throw new LogicException(sprintf('Cannot use the "date_format" option of the %s when the "widget" option is set to "single_text".', self::class));
286+
}
287+
288+
return $dateFormat;
289+
});
290+
$resolver->setNormalizer('date_widget', function (Options $options, $dateWidget) {
291+
if (null !== $dateWidget && 'single_text' === $options['widget']) {
292+
@trigger_error(sprintf('Using the "date_widget" option of the %s when the "widget" option is set to "single_text" is deprecated since Symfony 4.2 and will lead to an exception in 5.0.', self::class), E_USER_DEPRECATED);
293+
//throw new LogicException(sprintf('Cannot use the "date_widget" option of the %s when the "widget" option is set to "single_text".', self::class));
294+
}
295+
296+
return $dateWidget;
297+
});
298+
$resolver->setNormalizer('time_widget', function (Options $options, $timeWidget) {
299+
if (null !== $timeWidget && 'single_text' === $options['widget']) {
300+
@trigger_error(sprintf('Using the "time_widget" option of the %s when the "widget" option is set to "single_text" is deprecated since Symfony 4.2 and will lead to an exception in 5.0.', self::class), E_USER_DEPRECATED);
301+
//throw new LogicException(sprintf('Cannot use the "time_widget" option of the %s when the "widget" option is set to "single_text".', self::class));
302+
}
303+
304+
return $timeWidget;
305+
});
281306
}
282307

283308
/**

‎src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,9 @@ public function testDateTimeWithWidgetSingleText()
15061506
);
15071507
}
15081508

1509+
/**
1510+
* @group legacy
1511+
*/
15091512
public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets()
15101513
{
15111514
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.