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 e9cbc61

Browse filesBrowse files
committed
deprecate some options for single_text widgets
1 parent 100f205 commit e9cbc61
Copy full SHA for e9cbc61

File tree

7 files changed

+50
-3
lines changed
Filter options

7 files changed

+50
-3
lines changed

‎UPGRADE-4.3.md

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
UPGRADE FROM 4.2 to 4.3
2+
=======================
3+
4+
Form
5+
----
6+
7+
* Using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget` option is
8+
set to `single_text` is deprecated.

‎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
@@ -1602,6 +1602,9 @@ public function testDateTimeWithWidgetSingleText()
16021602
);
16031603
}
16041604

1605+
/**
1606+
* @group legacy
1607+
*/
16051608
public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets()
16061609
{
16071610
$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
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
4.3.0
5+
-----
6+
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`
9+
410
4.2.0
511
-----
612

‎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 %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);
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 %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);
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 %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);
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, TimezoneType
48+
DateTimeType, IntegerType, TimezoneType
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.