diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php index 79b3f7ac89..b521c95572 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php @@ -60,14 +60,14 @@ class ChoiceToBooleanArrayTransformer implements DataTransformerInterface throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e); } - $index = current($this->choiceList->getIndicesForChoices(array($choice))); + $valueMap = array_flip($this->choiceList->getValuesForChoices(array($choice))); foreach ($values as $i => $value) { - $values[$i] = $i === $index; + $values[$i] = isset($valueMap[$value]); } if ($this->placeholderPresent) { - $values['placeholder'] = false === $index; + $values['placeholder'] = 0 === count($valueMap); } return $values; diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php index a13c0d4d43..f1f13fda28 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php @@ -58,10 +58,10 @@ class ChoicesToBooleanArrayTransformer implements DataTransformerInterface throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e); } - $indexMap = array_flip($this->choiceList->getIndicesForChoices($array)); + $valueMap = array_flip($this->choiceList->getValuesForChoices($array)); foreach ($values as $i => $value) { - $values[$i] = isset($indexMap[$i]); + $values[$i] = isset($valueMap[$value]); } return $values; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index d26ee5f72a..d3d9187c0c 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -57,7 +57,7 @@ class ChoiceType extends AbstractType // Check if the choices already contain the empty value // Only add the empty value option if this is not the case - if (null !== $options['empty_value'] && 0 === count($options['choice_list']->getIndicesForValues(array('')))) { + if (null !== $options['empty_value'] && 0 === count($options['choice_list']->getChoicesForValues(array('')))) { $placeholderView = new ChoiceView(null, '', $options['empty_value']); // "placeholder" is a reserved index @@ -120,7 +120,7 @@ class ChoiceType extends AbstractType // Check if the choices already contain the empty value // Only add the empty value option if this is not the case - if (null !== $options['empty_value'] && 0 === count($options['choice_list']->getIndicesForValues(array('')))) { + if (null !== $options['empty_value'] && 0 === count($options['choice_list']->getChoicesForValues(array('')))) { $view->vars['empty_value'] = $options['empty_value']; }