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>
1 Answer 1
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();
}
}
-
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?Radu Dascălu– Radu Dascălu2016年09月28日 12:31:01 +00:00Commented 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– Marius2016年09月28日 12:32:51 +00:00Commented Sep 28, 2016 at 12:32