We need config.xml
file of your module in order to properly help you out. However we can give some hints based on the controller file that you have provided.
##Why Error Happends ?
Why Error Happends ?
The error is producing by this line which you can see in Foo_Bar_Adminhtml_BazController::gridAction()
$this->getLayout()->createBlock('Foo/adminhtml_Foo_grid')->toHtml()
Here createBlock()
function is used to create a new block in your layout. Reference to the block that you want to create is wrong and hence you are getting this error.
##Story Behind Error
Story Behind Error
In general createBlock()
has following structure:
createBlock('block_group_name/path_to_your_file')
block_group_name
stands for block unique reference in your module. In this case, you specified it asFoo
. This is defining insideconfig.xml
.In the general context Magento will look for block a class
Namespace_Module_Block_Path_To_Your_File
inapp\code\{local|community}\Namespace\Module\Block\Path\To\Your\File.php
(Here I assumeblock_group_name
is defined by the moduleNamespace_Module
). So it is very important to have the class name and file path follows same concept in your case.
##What You Should Check
What You Should Check
So possible errors are :
- Your block group name reference may be wrong. ie
Foo
is wrong. - Your block file path should be
app\code\community\Foo\Bar\Block\Adminhtml\Foo\Grid.php
- Class name should be
Foo_Bar_Block_Adminhtml_Foo_Grid
.
After recheck all these points, please make sure you cleared all cache.
EDIT
I can see your config.xml
file now. Based on this, the right code in your controller would be
$this->getLayout()->createBlock('foo_bar/adminhtml_foo_grid')->toHtml()