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

Skip to content

Commit 29f1daf

Browse files
committed
deprecate some options for single_text widgets
1 parent 5a0cad2 commit 29f1daf

File tree

4 files changed

+30
-2
lines changed
< 8000 button class="Button Button--iconOnly Button--invisible" aria-label="Open diff view settings" id=":R1stdab:" aria-haspopup="true" aria-expanded="false" tabindex="0">

4 files changed

+30
-2
lines changed

UPGRADE-4.2.md

Lines 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

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 `scale` option was removed from the `IntegerType`.
7678
* The `$scale` argument of the `IntegerToLocalizedStringTransformer` was removed.
7779

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.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

Lines changed: 24 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,28 @@ 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.', self::class), E_USER_DEPRECATED);
285+
}
286+
287+
return $dateFormat;
288+
});
289+
$resolver->setNormalizer('date_widget', function (Options $options, $dateWidget) {
290+
if (null !== $dateWidget && 'single_text' === $options['widget']) {
291+
@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.', self::class), E_USER_DEPRECATED);
292+
}
293+
294+
return $dateWidget;
295+
});
296+
$resolver->setNormalizer('time_widget', function (Options $options, $timeWidget) {
297+
if (null !== $timeWidget && 'single_text' === $options['widget']) {
298+
@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.', self::class), E_USER_DEPRECATED);
299+
}
300+
301+
return $timeWidget;
302+
});
281303
}
282304

283305
/**

0 commit comments

Comments
 (0)
0