Skip to content

Commit fe98608

Browse files
committed
simplify getSourceAsArray
1 parent 20d5ddb commit fe98608

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

code/DropdownImageField.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,9 @@ public function getSourceAsArray() {
8989
$source = $this->getSource();
9090
if (is_array($source)) {
9191
return $source;
92-
} else {
93-
$sourceArray = array();
94-
foreach ($source as $object) {
95-
$sourceArray[$object->{$this->keyField}] = $object->{$this->labelField};
96-
}
9792
}
98-
return $sourceArray;
93+
94+
return $source->map($this->keyField, $this->labelField)->toArray();
9995
}
10096

10197
}

0 commit comments

Comments
 (0)