I have added a menu option in the system | configuration panel but when I click on the link I get the below error

Fatal error: Call to a member function toOptionArray() on a non-object in /Users/myName/Sites/magentoDevTest/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php on line 463

I was hoping to try and solve this problem by looking at the core code, but I have not been successful with that approach, Ive looked around online but cant finds anything that has helped me

My system.xml file is

<tabs><!--creates tabs on the adminhtml page-->
    <training translate="label" module="training">
        <label>Training</label><!--creates a tab with the title of Training (a menu's title is called title a tabs title is called training)-->
        <sort_order>102</sort_order><!--the order of the tab-->

<sections><!--creates a section on under the tab called animal-->
    <training translate="label" module="training"><!--maps to <config><tabs><training> in this xml doc (system.xml)-->
        <label>Animal</label><!--names the bar animal-->
        <sort_order>10</sort_order><!--order of the bar-->
        <tab>training</tab><!--maps to <config><tabs><training> must be the same casing as the tab it maps to-->
        <show_in_default>1</show_in_default><!--shows this tab in a website scope-->
        <show_in_website>1</show_in_website><!--shows this tab in a website scope-->
        <show_in_store>1</show_in_store><!--shows this tab in a website scope-->
        <groups><!--sets the blue bar in the main content area of the page-->
            <general translate="label" module="training">
                <label>General Settings</label><!--sets the blue bars title-->
                <sort_order>10</sort_order><!--sets the order of the bar-->
                <show_in_default>1</show_in_default><!--shows this tab in a website scope-->
                <show_in_website>1</show_in_website><!--shows this tab in a website scope-->
                <show_in_store>1</show_in_store><!--shows this tab in a website scope-->
                <fields><!--sets which fields are available in the "general" bar-->
                    <recommendation translate="label comment" module="training">
                        <label>Recommendation</label><!--creates a option called recommentaion-->
                        <frontend_type>text</frontend_type><!--What does this do?-->
                        <sort_order>10</sort_order><!--sets the sort order of this field-->
                        <show_in_default>1</show_in_default><!--shows this tab in a website scope-->
                        <show_in_website>1</show_in_website><!--shows this tab in a website scope-->
                        <show_in_store>1</show_in_store><!--shows this tab in a website scope-->
                        <depends><!--This refers to <show_recommendations> node and is required for <show_recommendations> to be displayed-->
                        <comment><![CDATA[<strong>This</strong> is a comment]]></comment><!--what does this do?-->
                    <show_recommendation translate="label" module="training">
                        <label>Display Recommendations</label><!--creates a option called display recommentaion-->
                        <frontend_type>select</frontend_type><!--whats this do?-->
                        <source_model>training/system_config_source_show</source_model><!--sets the source model tha will be used?-->
                        <sort_order>20</sort_order><!--sets the order-->
                        <show_in_default>1</show_in_default><!--shows this tab in a website scope-->
                        <show_in_website>1</show_in_website><!--shows this tab in a website scope-->
                        <show_in_store>1</show_in_store><!--shows this tab in a website scope-->
                        <tooltip>More Javascript in use!</tooltip><!--shows text on hover-->



        <training><!--Namespace name-->
            <class>Training_Animal_Model</class><!--File path to the model directory-->
            <resourceModel>training_animal_resource</resourceModel><!--maps to resource model node-->
  • Please also post your config.xml, especially the part that includes your models (inside the global tag) Commented Sep 9, 2013 at 13:24

4 Answers 4


Most probably this is the issue :


When declaring a source model for a field in system.xml, Magento will try to retrieve the options for the field by calling:

Mage::getModel('source model here')->toOptionArray();

So in your case it tries :


and Mage::getModel('training/system_config_source_show') returns null. Make sure the model exists.

  • That's defiantly the problem (i removed the <depends> node and <show_recommendation> to confirm). I have looked in config.xml and my model is defined in there. So do I need a file path of system_config_source_show.php in my models folder? if so what am I extending? I have added the relevant part of my config.xml
    – tony09uk
    Commented Sep 9, 2013 at 13:42
  • 1
    It's not important what you are extending. You can even have a class that does not extend anything. Just make sure you have the method toOptionArray() that returns an array (Duh!). array('value1'=>'label1', 'value2'=>'label2')`
    – Marius
    Commented Sep 9, 2013 at 14:41
  • Just a notice: I've frequently had the same issue when someone installed one of my modules, but forgot to refresh the Magento Compiler or flush the PHP accelerator cache (OPCache or APC when the check-filestamp option was off). I'm quite sure it is not related to the original post, but it might be useful to people who end up here through search ;) Commented Feb 13, 2015 at 17:24

copy app\code\core\Mage\Adminhtml\Block\System\Config\Form.php

paste / extend to / create app\code\local\Mage\Adminhtml\Block\System\Config\Form.php

find the following on line 463

$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');

and replace it with:

   $optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
} else {
  • So this fixes my issue but doesn't seem to be logging anything. When I revert, it goes back to a blank screen and the same error as above. Why do you think it wouldn't be logging?
    – sparecycle
    Commented Feb 17, 2015 at 19:39
  • i want to see your site kindly give link thanks Commented Feb 18, 2015 at 3:54
  • Have the same issue with a 3rd party module. Can confirm this answer provides a work-around. Logfile still gives no clue, just complains that $e is undefined as well: 2015-12-18T19:55:04+00:00 ERR (3): Notice: Undefined variable: e in /var/www/dev/htdocs/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php on line 466 2015-12-18T19:55:04+00:00 ERR (3): Notice: Trying to get property of non-object in /var/www/dev/htdocs/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php on line 466 If someone knows how to further troubleshoot this, feel free to add a comment or an answer.
    – Ottonet
    Commented Dec 18, 2015 at 20:11
  • It's a bad practice to modify the core.
    – Nolwennig
    Commented Jan 19, 2016 at 14:14
  • Hi @Nolwennig just paste / extend to / create app\code\local\Mage\Adminhtml\Block\System\Config\Form.php Commented Jul 19, 2016 at 4:10

In my case, I solved it with the following steps:-

  1. Disable Compilation (System -> Tools -> Compilation)
  2. Refresh Cache (System -> Cache Management)

Create file in app/code/local/Training/Animal/Model/System/Config/Source/Show.php


class Training_Animal_Model_System_Config_Source_Show {

    public function toOptionArray() {
        return array(
            array('value' => 0, 'label'=>Mage::helper('training')->__('Load all recommendation')),
            array('value' => 1, 'label'=>Mage::helper('training')->__('Show only available recommendation')),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.