Reputation: 31
I get this error when I try to access System > Configuration > Advanced > System
Fatal error: Call to a member function toOptionArray() on a non-object in /home/server/public_html/store/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php on line 421
I found this answer: Fatal error: Call to a member function toOptionArray()
However, the code that needs to be replaced according to that answer is different from the code in that file (Form.php):
if ($method) {
if ($fieldType == 'multiselect') {
$optionArray = $sourceModel->$method();
} else {
$optionArray = array();
foreach ($sourceModel->$method() as $value => $label) {
$optionArray[] = array('label' => $label, 'value' => $value);
}
}
} else {
$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
}
$field->setValues($optionArray);
}
}
}
return $this;
Any ideas? Thanks!
Upvotes: 0
Views: 1884
Reputation: 26006
The following steps should solve the error:-
System -> Tools -> Compilation
) System -> Cache Management
)Upvotes: 0
Reputation: 1018
If you look in Form.php from line 398 to 425 you have almost the same code. The code from your answer isn't a fix, is just a way to help you determine your real problem, so you can use that code:
if(is_object($sourceModel)){
$field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
} else {
Mage::log($e->source_model);
}
And then you would have to look into the Magento log file to see what happened. Also you can try to log debug_print_backtrace(); Probably your problem comes from a badly written extension.
Upvotes: 1