diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php index 489030cd7af12..7806ac2d8e87e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php @@ -2551,12 +2551,8 @@ public function testTimezone() [@name="name"] [@class="my&class form-control"] [not(@required)] - [./optgroup - [@label="Europe"] - [./option[@value="Europe/Vienna"][@selected="selected"][.="Vienna"]] - ] - [count(./optgroup)>10] - [count(.//option)>200] + [./option[@value="Europe/Vienna"][@selected="selected"][.="Europe / Vienna"]] + [count(./option)>200] ' ); } @@ -2572,8 +2568,7 @@ public function testTimezoneWithPlaceholder() '/select [@class="my&class form-control"] [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Timezone[/trans]"]] - [count(./optgroup)>10] - [count(.//option)>201] + [count(./option)>201] ' ); } diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index ae21b1de9d590..e41c46e907a89 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -48,6 +48,7 @@ CHANGELOG * dispatch `PreSetDataEvent` on `form.pre_set_data` * dispatch `PostSetDataEvent` on `form.post_set_data` * added an `input` option to `NumberType` + * removed default option grouping in `TimezoneType`, use `group_by` instead 4.2.0 ----- diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php index 02e319d0ecf38..54968e6799615 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php @@ -94,22 +94,9 @@ private static function getTimezones(int $regions, string $input): array continue; } - $parts = explode('/', $timezone); - - if (\count($parts) > 2) { - $region = $parts[0]; - $name = $parts[1].' - '.$parts[2]; - } elseif (\count($parts) > 1) { - $region = $parts[0]; - $name = $parts[1]; - } else { - $region = 'Other'; - $name = $parts[0]; - } - - $timezones[$region][str_replace('_', ' ', $name)] = $timezone; + $timezones[str_replace(['/', '_'], [' / ', ' '], $timezone)] = $timezone; } - return 1 === \count($timezones) ? reset($timezones) : $timezones; + return $timezones; } } diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index c85b449346672..b03ac0f9fc4d9 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -2278,12 +2278,8 @@ public function testTimezone() '/select [@name="name"] [not(@required)] - [./optgroup - [@label="Europe"] - [./option[@value="Europe/Vienna"][@selected="selected"][.="Vienna"]] - ] - [count(./optgroup)>10] - [count(.//option)>200] + [./option[@value="Europe/Vienna"][@selected="selected"][.="Europe / Vienna"]] + [count(./option)>200] ' ); } @@ -2298,8 +2294,7 @@ public function testTimezoneWithPlaceholder() $this->assertWidgetMatchesXpath($form->createView(), [], '/select [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Timezone[/trans]"]] - [count(./optgroup)>10] - [count(.//option)>201] + [count(./option)>201] ' ); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php index cd645779088e9..8e1fee8d3628d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php @@ -22,11 +22,8 @@ public function testTimezonesAreSelectable() $choices = $this->factory->create(static::TESTED_TYPE) ->createView()->vars['choices']; - $this->assertArrayHasKey('Africa', $choices); - $this->assertContains(new ChoiceView('Africa/Kinshasa', 'Africa/Kinshasa', 'Kinshasa'), $choices['Africa'], '', false, false); - - $this->assertArrayHasKey('America', $choices); - $this->assertContains(new ChoiceView('America/New_York', 'America/New_York', 'New York'), $choices['America'], '', false, false); + $this->assertContains(new ChoiceView('Africa/Kinshasa', 'Africa/Kinshasa', 'Africa / Kinshasa'), $choices, '', false, false); + $this->assertContains(new ChoiceView('America/New_York', 'America/New_York', 'America / New York'), $choices, '', false, false); } public function testSubmitNull($expected = null, $norm = null, $view = null) @@ -83,7 +80,7 @@ public function testFilterByRegions() $choices = $this->factory->create(static::TESTED_TYPE, null, ['regions' => \DateTimeZone::EUROPE]) ->createView()->vars['choices']; - $this->assertContains(new ChoiceView('Europe/Amsterdam', 'Europe/Amsterdam', 'Amsterdam'), $choices, '', false, false); + $this->assertContains(new ChoiceView('Europe/Amsterdam', 'Europe/Amsterdam', 'Europe / Amsterdam'), $choices, '', false, false); } /**
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: