diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php index 5032ef4b761d..670d55f28086 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php @@ -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); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php b/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php index e4fd0622a4ef..1c5526283ff9 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php @@ -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); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php index 04f25a62f206..1e82b9850569 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php @@ -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); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php b/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php index 2622e3222410..3499ca06af13 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php @@ -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); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php index 4886b3407dc0..9831f795895c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php @@ -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 @@ -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'))); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php index 71c374b468dd..c91f7c0ff51e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php @@ -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 @@ -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'))); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php index 5cf578d442b2..8d469d2b41ba 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php @@ -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 @@ -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'))); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php index b6cf1e1b17d4..ac1a65ad1fb9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php @@ -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 @@ -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'))); + } }