1

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

<?php
class Mymodule_Wine_Block_Adminhtml_Wine_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
 public function __construct()
 {
 parent::__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:

<blocks>
 <wine>
 <class>Mymodule_Wine_Block</class>
 </wine>
</blocks>
Marius
199k55 gold badges431 silver badges837 bronze badges
asked Sep 28, 2016 at 10:38

1 Answer 1

2

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

<?php 
class Mymodule_Wine_Block_Adminhtml_Wine_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
 protected function _prepareForm()
 {
 $form = new Varien_Data_Form(
 array(
 'id' => 'edit_form',
 'action' => $this->getUrl(
 '*/*/save',
 array(
 'id' => $this->getRequest()->getParam('id')
 )
 ),
 'method' => 'post',
 'enctype' => 'multipart/form-data' //add this only if you have file uploads
 )
 );
 $form->setUseContainer(true);
 $this->setForm($form);
 return parent::_prepareForm();
 }
}
answered Sep 28, 2016 at 11:05
2
  • 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. Commented Sep 28, 2016 at 12:32

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.