8000 deprecate some options for single_text widgets · symfony/symfony@e9cbc61 · GitHub
[go: up one dir, main page]

Skip to content

Commit e9cbc61

Browse files
committed
deprecate some options for single_text widgets
1 parent 100f205 commit e9cbc61

File tree

7 files changed

+50
-3
lines changed

7 files changed

+50
-3
lines changed

UPGRADE-4.3.md

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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