Skip to content

Commit

Permalink
bug #29500 [Form] filter out invalid Intl values (xabbuh)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

[Form] filter out invalid Intl values

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23679
| License       | MIT
| Doc PR        |

Commits
-------

a2d6940 filter out invalid Intl values
  • Loading branch information
nicolas-grekas committed Dec 8, 2018
2 parents fc8dc91 + a2d6940 commit 7a46c98
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 20 deletions.
Expand Up @@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
return array();
}

// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}

return $this->loadChoiceList($value)->getChoicesForValues($values);
}

Expand Down
Expand Up @@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
return array();
}

// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}

return $this->loadChoiceList($value)->getChoicesForValues($values);
}

Expand Down
Expand Up @@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
return array();
}

// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}

return $this->loadChoiceList($value)->getChoicesForValues($values);
}

Expand Down
5 changes: 0 additions & 5 deletions src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php
Expand Up @@ -89,11 +89,6 @@ public function loadChoicesForValues(array $values, $value = null)
return array();
}

// If no callable is set, values are the same as choices
if (null === $value) {
return $values;
}

return $this->loadChoiceList($value)->getChoicesForValues($values);
}

Expand Down
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Intl\Util\IntlTestHelper;

class CountryTypeTest extends BaseTypeTest
Expand Down Expand Up @@ -61,4 +62,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'FR', $expectedD
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}

public function testInvalidChoiceValuesAreDropped()
{
$type = new CountryType();

$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\CurrencyType;
use Symfony\Component\Intl\Util\IntlTestHelper;

class CurrencyTypeTest extends BaseTypeTest
Expand Down Expand Up @@ -44,4 +45,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'EUR', $expected
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}

public function testInvalidChoiceValuesAreDropped()
{
$type = new CurrencyType();

$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
use Symfony\Component\Intl\Util\IntlTestHelper;

class LanguageTypeTest extends BaseTypeTest
Expand Down Expand Up @@ -54,4 +55,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'en', $expectedD
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}

public function testInvalidChoiceValuesAreDropped()
{
$type = new LanguageType();

$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\LocaleType;
use Symfony\Component\Intl\Util\IntlTestHelper;

class LocaleTypeTest extends BaseTypeTest
Expand Down Expand Up @@ -44,4 +45,11 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'en', $expectedD
{
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}

public function testInvalidChoiceValuesAreDropped()
{
$type = new LocaleType();

$this->assertSame(array(), $type->loadChoicesForValues(array('foo')));
}
}

0 comments on commit 7a46c98

Please sign in to comment.