BUGFIX If DropdownField->Field() lack of source checking before looping through it

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64320 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2008-10-15 23:25:55 +00:00
parent 5865fd19d1
commit 972558df3f

View File

@ -70,20 +70,22 @@ class DropdownField extends FormField {
$options = '';
$source = $this->getSource();
foreach($source as $value => $title) {
$selected = ($value == $this->value) ? 'selected' : null;
if($selected && $this->value != 0) {
$this->isSelected = true;
if($source) {
foreach($source as $value => $title) {
$selected = ($value == $this->value) ? 'selected' : null;
if($selected && $this->value != 0) {
$this->isSelected = true;
}
$options .= $this->createTag(
'option',
array(
'selected' => $selected,
'value' => $value
),
$title
);
}
$options .= $this->createTag(
'option',
array(
'selected' => $selected,
'value' => $value
),
$title
);
}
$attributes = array(