Trying to create a custom module to upload .xls file to the magento database. This is the error I get after creating the Edit block for the dashboard:

Fatal error: Call to a member function setData() on boolean in /opt/lampp/htdocs/magento/app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php on line 141

This is my Mymodule/Wine/Block/Adminhtml/Wine/Edit.php


class Mymodule_Wine_Block_Adminhtml_Wine_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
    public function __construct()

        $this->_objectId     = 'id';
        $this->_blockGroup = 'wine';
        $this->_controller    = 'adminhtml_wine';

        $this->_updateButton('save', 'label', Mage::helper('wine')->__('Save Changes'));
        $this->_updateButton('delete', 'label', Mage::helper('wine')->__('Delete Item'));

    public function getHeaderText()
        if (Mage::registry('wine_data') && Mage::registry('wine_data')->getId()) {
            return Mage::helper('wine')->__('Edit Item \'%s\'', $this->htmlEscape(Mage::registry('wine_data')->getTitle()));
        } else {
            return Mage::helper('wine')->__('Upload .xls file');

And this is the part of config.xml which corresponds to blocks:


1 Answer 1


I think you are missing the file Mymodule/Wine/Block/Adminhtml/Wine/Edit/Form.php
This should be its content:

class Mymodule_Wine_Block_Adminhtml_Wine_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
    protected function _prepareForm()
        $form = new Varien_Data_Form(
                'id'         => 'edit_form',
                'action'     => $this->getUrl(
                        'id' => $this->getRequest()->getParam('id')
                'method'     => 'post',
                'enctype'    => 'multipart/form-data' //add this only if you have file uploads
        return parent::_prepareForm();
  • Thank you, you were right, I did not make the Form.php file. Any resource where are described all the dependencies for Magento 1.9 modules? Commented Sep 28, 2016 at 12:31
  • @RaduDascălu. Sorry I don't know one. I''m sure there are, but I don't know them.
    – Marius
    Commented Sep 28, 2016 at 12:32

Your Answer

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

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