Skip to content

Commit

Permalink
[Form] Replace unset() with non-destructive logic in case the "choice…
Browse files Browse the repository at this point in the history
…s" option is an object.
  • Loading branch information
Jeremy Mikola committed Sep 9, 2010
1 parent 50f0398 commit 6fc9b68
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Symfony/Component/Form/ChoiceField.php
Expand Up @@ -43,11 +43,12 @@ protected function configure()

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);
Expand Down

0 comments on commit 6fc9b68

Please sign in to comment.