diff --git a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php index b1e6b3bf06..e979455ef3 100644 --- a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php @@ -141,7 +141,7 @@ class ArrayChoiceList implements ChoiceListInterface $choices = array(); foreach ($values as $i => $givenValue) { - if (isset($this->choices[$givenValue])) { + if (array_key_exists($givenValue, $this->choices)) { $choices[$i] = $this->choices[$givenValue]; } } diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php index 03cb7fce57..9ea5f631a1 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php @@ -130,4 +130,11 @@ class ArrayChoiceListTest extends AbstractChoiceListTest $this->assertSame(array(2 => 'value2'), $choiceList->getValuesForChoices(array(2 => $obj2))); $this->assertSame(array(2 => 'value2'), $choiceList->getValuesForChoices(array(2 => (object) array('value' => 'value2')))); } + + public function testGetChoicesForValuesWithContainingNull() + { + $choiceList = new ArrayChoiceList(array('Null' => null)); + + $this->assertSame(array(0 => null), $choiceList->getChoicesForValues(array('0'))); + } }