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

Skip to content

Commit 89ff331

Browse files
committed
deprecate some options for single_text widgets
1 parent 5aa0967 commit 89ff331

File tree

7 files changed

+44
-3
lines changed

7 files changed

+44
-3
lines changed

UPGRADE-4.3.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Config
1313

1414
* Deprecated using environment variables with `cannotBeEmpty()` if the value is validated with `validate()`
1515

16+
Form
17+
----
18+
19+
* Using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget` option is
20+
set to `single_text` is deprecated.
21+
1622
FrameworkBundle
1723
---------------
1824

UPGRADE-5.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Finder
7676
Form
7777
----
7878

79+
* Using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget` option is
80+
set to `single_text` is not supported anymore.
7981
* The `getExtendedType()` method was removed from the `FormTypeExtensionInterface`. It is replaced by the the static
8082
`getExtendedTypes()` method which must return an iterable of extended types.
8183

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', [

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGELOG
44
4.3.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
* added `block_prefix` option to `BaseType`.
810

911
4.2.0

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ public function configureOptions(OptionsResolver $resolver)
216216

217217
// Defaults to the value of "widget"
218218
$dateWidget = function (Options $options) {
219-
return $options['widget'];
219+
return 'single_text' === $options['widget'] ? null : $options['widget'];
220220
};
221221

222222
// Defaults to the value of "widget"
223223
$timeWidget = function (Options $options) {
224-
return $options['widget'];
224+
return 'single_text' === $options['widget'] ? null : $options['widget'];
225225
};
226226

227227
$resolver->setDefaults([
@@ -292,6 +292,31 @@ public function configureOptions(OptionsResolver $resolver)
292292
'text',
293293
'choice',
294294
]);
295+
296+
$resolver->setDeprecated('date_format', function (Options $options, $dateFormat) {
297+
if (null !== $dateFormat && 'single_text' === $options['widget']) {
298+
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);
299+
//throw new LogicException(sprintf('Cannot use the "date_format" option of the %s when the "widget" option is set to "single_text".', self::class));
300+
}
301+
302+
return '';
303+
});
304+
$resolver->setDeprecated('date_widget', function (Options $options, $dateWidget) {
305+
if (null !== $dateWidget && 'single_text' === $options['widget']) {
306+
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);
307+
//throw new LogicException(sprintf('Cannot use the "date_widget" option of the %s when the "widget" option is set to "single_text".', self::class));
308+
}
309+
310+
return '';
311+
});
312+
$resolver->setDeprecated('time_widget', function (Options $options, $timeWidget) {
313+
if (null !== $timeWidget && 'single_text' === $options['widget']) {
314+
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);
315+
//throw new LogicException(sprintf('Cannot use the "time_widget" option of the %s when the "widget" option is set to "single_text".', self::class));
316+
}
317+
318+
return '';
319+
});
295320
}
296321

297322
/**

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', [

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