I'm trying to create a select list from a Magento collection using toOptionArray, but am unable to define the key => value relationship.
The lib/Varien/Data/Collection.php file contains the public & protected methods:
protected function _toOptionArray($valueField='id', $labelField='name', $additional=array())
{
$res = array();
$additional['value'] = $valueField;
$additional['label'] = $labelField;
foreach ($this as $item) {
foreach ($additional as $code => $field) {
$data[$code] = $item->getData($field);
}
$res[] = $data;
}
return $res;
}
public function toOptionArray()
{
return $this->_toOptionArray();
}
But it appears that the public function does not pass any arguments to the protected function, which would seem to limit the functionality of the method. Is this a bug, or is there a standard way to generate a select from a collection that does not inherit from the Collection class?
(it's easy enough to override the public method in my own class, but I'd like to know any insights on the design of the above)