Fatal error: Call to a member function toHtml() on a non-object
-
12-12-2019 - |
Question
I have custom module storelocator. Tabs used in the admin form. Below code is used to add tabs in the admin form.
$this->addTab('form_section_general', array(
'label' => Mage::helper('clarion_storelocator')->__('General'),
'title' => Mage::helper('clarion_storelocator')->__('General'),
'content' => $this->getLayout()->createBlock('clarion_storelocator/adminhtml_storelocator_edit_tab_form')->toHtml(),
));
$this->addTab('form_section_google_map', array(
'label' => Mage::helper('clarion_storelocator')->__('Google Map'),
'title' => Mage::helper('clarion_storelocator')->__('Google Map'),
'content' => $this->getLayout()->createBlock('clarion_storelocator/adminhtml_storelocator_edit_tab_googlemap')->toHtml(),
));
General tabs shows correctly. But gives error for the tab 'Google Map'. Error that i am getting is : Fatal error: Call to a member function toHtml() on a non-object.
Solution
make sure the block with alias clarion_storelocator/adminhtml_storelocator_edit_tab_googlemap
exists.
Also make sure there is no upper case letter in the file name.
I have a feeling your block file is named GoogleMap.php
.
If so, then rename it to Googlemap.php
or change the your code to look like this:
'content' => $this->getLayout()->createBlock('clarion_storelocator/adminhtml_storelocator_edit_tab_googleMap')->toHtml(),
OTHER TIPS
You just rename this Google.PHP to Google.php under
app/code/community/Clarion/Storelocator/Block/Adminhtml/Storelocator/Edit/Tab/Googlemap.php.
The extension with all caps seems to be the problem.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange