From 6fc9b68fa7b54c916d0d6d3fa527eeda10569b6f Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Wed, 30 Jun 2010 20:15:55 -0400 Subject: [PATCH] [Form] Replace unset() with non-destructive logic in case the "choices" option is an object. --- src/Symfony/Component/Form/ChoiceField.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Form/ChoiceField.php b/src/Symfony/Component/Form/ChoiceField.php index b518cc6383..ba92920b75 100644 --- a/src/Symfony/Component/Form/ChoiceField.php +++ b/src/Symfony/Component/Form/ChoiceField.php @@ -43,11 +43,12 @@ class ChoiceField extends HybridField foreach ($this->getOption('preferred_choices') as $choice) { $this->add($this->newChoiceField($choice, $choices[$choice])); - unset($choices[$choice]); } foreach ($this->getOption('choices') as $choice => $value) { - $this->add($this->newChoiceField($choice, $value)); + if (!isset($this->preferredChoices[$choice])) { + $this->add($this->newChoiceField($choice, $value)); + } } } else { $this->setFieldMode(self::FIELD);