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.

asked Apr 3, 2015 at 12:58

2 Answers 2

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.

answered Apr 3, 2015 at 13:14
1
  • 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. Commented Apr 4, 2015 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.

Rakesh Donga
5,4442 gold badges26 silver badges58 bronze badges
answered Jan 23, 2019 at 13:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.