0

I have created configuration options. It works fine but i want to add dynamic dropdown values. For that i have created select field and added source_model.

which is in

Baka/Mama/Model/System/Config/Source/Selectsand

Folder.

in system.xml file i have created Following Field.

           <selectsand>
                        <label>Dropdown</label>
                        <comment>Dropdown with global scope.</comment>
                     <frontend_type>select</frontend_type>
                     <source_model>baka_mama/system_config_source_selectsand_values</source_model>
                        <sort_order>30</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                   </selectsand>

Fatal error: Call to a member function toOptionArray() on a non-object in C:\xampp\htdocs\magento\includes\src\Mage_Adminhtml_Block_System_Config_Form.php on line 463

in Values.php file i have added following code.

      class Baka_Mama_Model_System_Config_Source_Selectsand_Values{


public function toOptionArray()
{
return array(
  array('value' => 0, 'label' =>'Pizza'),
  array('value' => 1, 'label' => 'Pasta'),
  array('value' => 2, 'label' =>'Manchuriyan'),
 // and so on...
); 
}

Where am i making mistake? Need help to resolve it.

Any help would be appreciated.

1

Without having access to your source code we wont be able to definitively say where your problem likes.

The first place I would look is at the structure of your model. Can you instantiate it?

$model = Mage::getModel('baka_mama/system_config_source_selectsand_values'); echo get_class($model);

If that returns null or something other than your class then the problem likely likes in not using a correct model name, or the model file / class name combination is incorrect.

If it is being created and matches what you are expecting then post more information about the error. Especially the function where the problem is occurring as you have not identified a line number to be able to see what is happening when it gets that error.

| improve this answer | |
  • complete error message is : Fatal error: Call to a member function toOptionArray() on a non-object in C:\xampp\htdocs\magento\includes\src\Mage_Adminhtml_Block_System_Config_Form.php on line 463. do you have any solution. i have not created any Model file. this module is only to create configuration option. – Jack Torris Apr 4 '15 at 5:44
0
class Baka_Mama_Model_System_Config_Source_Selectsand_Values{

public function toOptionArray()
{

return array(

  array('value' => 0, 'label' =>Mage::helper('bakamama')->__('Pizza')),

  array('value' => 1, 'label' =>Mage::helper('bakamama')->__('Pasta')),

  array('value' => 2, 'label' =>Mage::helper('bakamama')->__('Manchuriyan')),
 // and so on...

); 

}

Inside the Mage::helper , 'bakamama' refers to the module name you have given in your system.xml and config.xml file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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