Skip to content

Commit

Permalink
filter out invalid language values
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Dec 7, 2018
1 parent 9e84e0f commit 7c15267
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 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 @@ -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')));
}
}

0 comments on commit 7c15267

Please sign in to comment.