8000 [Form] Fixed empty conversion of Intl types · symfony/symfony@6e58155 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6e58155

Browse files
committed
[Form] Fixed empty conversion of Intl types
1 parent ac8fca5 commit 6e58155

File tree

7 files changed

+26
-0
lines changed

7 files changed

+26
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function loadChoiceList($value = null)
7575
public function loadChoicesForValues(array $values, $value = null)
7676
{
7777
// Optimize
78+
$values = array_filter($values);
7879
if (empty($values)) {
7980
return array();
8081
}
@@ -93,6 +94,7 @@ public function loadChoicesForValues(array $values, $value = null)
9394
public function loadValuesForChoices(array $choices, $value = null)
9495
{
9596
// Optimize
97+
$choices = array_filter($choices);
9698
if (empty($choices)) {
9799
return array();
98100
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function loadChoiceList($value = null)
7474
*/
7575
public function loadChoicesForValues(array $values, $value = null)
7676
{
77+
$values = array_filter($values);
7778
// Optimize
7879
if (empty($values)) {
7980
return array();
@@ -92,6 +93,7 @@ public function loadChoicesForValues(array $values, $value = null)
9293
*/
9394
public function loadValuesForChoices(array $choices, $value = null)
9495
{
96+
$choices = array_filter($choices);
9597
// Optimize
9698
if (empty($choices)) {
9799
return array();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function loadChoiceList($value = null)
7474
*/
7575
public function loadChoicesForValues(array $values, $value = null)
7676
{
77+
$values = array_filter($values);
7778
// Optimize
7879
if (empty($values)) {
7980
return array();
@@ -92,6 +93,7 @@ public function loadChoicesForValues(array $values, $value = null)
9293
*/
9394
public function loadValuesForChoices(array $choices, $value = null)
9495
{
96+
$choices = array_filter($choices);
9597
// Optimize
9698
if (empty($choices)) {
9799
return array();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function loadChoiceList($value = null)
7474
*/
7575
public function loadChoicesForValues(array $values, $value = null)
7676
{
77+
$values = array_filter($values);
7778
// Optimize
7879
if (empty($values)) {
7980
return array();
@@ -92,6 +93,7 @@ public function loadChoicesForValues(array $values, $value = null)
9293
*/
9394
public function loadValuesForChoices(array $choices, $value = null)
9495
{
96+
$choices = array_filter($choices);
9597
// Optimize
9698
if (empty($choices)) {
9799
return array();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function loadChoiceList($value = null)
7171
*/
7272
public function loadChoicesForValues(array $values, $value = null)
7373
{
74+
$values = array_filter($values);
7475
// Optimize
7576
if (empty($values)) {
7677
return array();
@@ -89,6 +90,7 @@ public function loadChoicesForValues(array $values, $value = null)
8990
*/
9091
public function loadValuesForChoices(array $choices, $value = null)
9192
{
93+
$choices = array_filter($choices);
9294
// Optimize
9395
if (empty($choices)) {
9496
return array();

src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,12 @@ public function testCurrenciesAreSelectable()
3434
$this->assertContains(new ChoiceView('USD', 'USD', 'US Dollar'), $choices, '', false, false);
3535
$this->assertContains(new ChoiceView('SIT', 'SIT', 'Slovenian Tolar'), $choices, '', false, false);
3636
}
37+
38+
public function testSubmitNull()
39+
{
40+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CurrencyType');
41+
$form->submit(null);
42+
43+
$this->assertNull($form->getData());
44+
}
3745
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,12 @@ public function testTimezonesAreSelectable()
2727
$this->assertArrayHasKey('America', $choices);
2828
$this->assertContains(new ChoiceView('America/New_York', 'America/New_York', 'New York'), $choices['America'], '', false, false);
2929
}
30+
31+
public function testSubmitNull()
32+
{
33+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\TimezoneType');
34+
$form->submit(null);
35+
36+
$this->assertNull($form->getData());
37+
}
3038
}

0 commit comments

Comments
 (0)
0