[Form] Replace unset() with non-destructive logic in case the "choices" option is an object.

This commit is contained in:
Jeremy Mikola 2010-06-30 20:15:55 -04:00
parent 50f039844b
commit 6fc9b68fa7

View File

@ -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);