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 882a4cc

Browse filesBrowse files
committed
deprecate some options for single_text widgets
1 parent bc816da commit 882a4cc
Copy full SHA for 882a4cc

File tree

7 files changed

+40
-3
lines changed
Filter options

7 files changed

+40
-3
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 `getExtendedType()` method of the `FormTypeExtensionInterface` is deprecated and will be removed in 5.0. Type
5961
extensions must implement the static `getExtendedTypes()` method instead and return an iterable of extended types.
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 `getExtendedType()` method was removed from the `FormTypeExtensionInterface`. It is replaced by the the static
7678
`getExtendedTypes()` method which must return an iterable of extended types.
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
* The `getExtendedType()` method of the `FormTypeExtensionInterface` is deprecated and will be removed in 5.0. Type
810
extensions must implement the static `getExtendedTypes()` method instead and return an iterable of extended types.
911

‎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->setDeprecated('date_format', function (Options $options, $dateFormat) {
283+
if (null !== $dateFormat && 'single_text' === $options['widget']) {
284+
return 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);
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 '';
289+
});
290+
$resolver->setDeprecated('date_widget', function (Options $options, $dateWidget) {
291+
if (null !== $dateWidget && 'single_text' === $options['widget']) {
292+
return 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);
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 '';
297+
});
298+
$resolver->setDeprecated('time_widget', function (Options $options, $timeWidget) {
299+
if (null !== $timeWidget && 'single_text' === $options['widget']) {
300+
return 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);
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 '';
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(

‎src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testDebugDeprecatedDefaults()
4545
Built-in form types (Symfony\Component\Form\Extension\Core\Type)
4646
----------------------------------------------------------------
4747
48-
IntegerType
48+
DateTimeType, IntegerType
4949
5050
Service form types
5151
------------------

0 commit comments

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