So, while creating a form, I got the following error:
Fatal error: Call to a member function setData() on a non-object in app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php on line 129
It took me some time to figure out what going on, and after some digging in mage widget forms, I understood the error. In fact, Magento is not finding the form associated to the form container.
Basically for container to locate the form, it needs 3 attributes, an example below:
protected $_blockGroup = 'training_commenteav';
protected $_controller = 'adminhtml_eav_comment';
protected $_mode = 'edit';
These specify the location of the form. In the parent class, here what's happening:
$this->getLayout()->createBlock($this->_blockGroup . '/' . $this->_controller . '_' . $this->_mode . '_form')
So for my example it would be "training_commenteav/adminhtml_eav_comment_edit_form" that it will use to create a block instance.
I don't know why you can't just specify the uri of the form as I would have expected. Instead it uses blockgroup, controller and mode. Maybe you could have an abstract class for several modes and reuse the blockgroup and controller which I don't think is that useful. Anyway that is how Magento works with widget forms.
You took a whole lot of trouble providing us with some answers for these types of problem. I give you my appreciation for that. Looking forward for more solutions for magento-related problems.
ReplyDeleteRelally great information..thx for sharing
ReplyDeleteThanks,
ReplyDeleteI've been watching at this error for two days ;) Solved.
Very useful information, you've inspired to look into the core more, thanks!
ReplyDeleteThank you very much! I was just to start hitting the wall with my head :)
ReplyDeleteYou are amazing. Now I always check magento's classes. Thanks
ReplyDeleteThanks a lot!! It really help me solve my form trouble.
ReplyDeleteThanks man, saved my life in work ;)
ReplyDeleteThanks for your post. It's not clear from the first look. I couldn't understood how magento get block path
ReplyDeleteWow! This could be one particular of the most beneficial blogs We’ve ever arrive across on this subject. Basically Wonderful. I am also a specialist in this topic therefore I can understand your effort.
ReplyDeleteMagento certified developers Adelaide
This comment has been removed by the author.
ReplyDeleteI have installed quick start third party theme. After installation i am getting following error. In localhost it is working fine but when i upload to the server i am facing the error.
ReplyDeleteFatal error: Call to a member function setData() on a non-object in /app/code/local/EM/Ajaxblock/controllers/IndexController.php on line 15
This is IndexController.php
getRequest()->getParam('data');
$data = base64_decode($data);
$data = json_decode($data);
$result = array();
foreach($data as $key => $value)
{
$result[$key] = $value;
}
//print_r($result);die;
$block = $this->getLayout()->createBlock($result['type']);
$block->setData($result);
if($result['type'] == 'tabs/group')
{
$block->setTemplate('emtabs/group.phtml');
}
echo $block->toHtml();
die;
}
}
Please Help.. Thanks in advance..
This comment has been removed by the author.
ReplyDeleteFor instance, Magento's eCommerce Shopping Cart is a platform, which was specifically designed to pander to businesses with owners, who rather sell their products and/or services online.https://medijo.lt/skrajutes/
ReplyDeleteI really thank you for the valuable info on this great subject and look forward to more great posts. Thanks a lot for enjoying this beauty article with me. I am appreciating it very much! Looking forward to another great article. Good luck to the author! All the best! Magento webshop laten bouwen
ReplyDelete