The parent::__construct(); function is causing problems as setData() says there is no object, for a simple block

magento

Solution

Assuming you're dealing with an unadulterated version of Magento, take a look at line 129

127:    public function getFormHtml()
128:    {
129:        $this->getChild('form')->setData('action', $this->getSaveUrl());
130:        return $this->getChildHtml('form');
131:    }

You can see the attempt to fetch the child block named form fails to return an object. Most likely, that's because up in the prepare layout method, Magento failed to instantiate the form

protected function _prepareLayout()
{
    if ($this->_blockGroup && $this->_controller && $this->_mode) {
        $this->setChild('form', $this->getLayout()->createBlock($this->_blockGroup . '/' . $this->_controller . '_' . $this->_mode . '_form'));
    }
    return parent::_prepareLayout();
}

either because one of the following variables wasn't set on your class

$this->_blockGroup
$this->_controller
$this->_mode

or the class alias generated by the string

$this->_blockGroup . '/' . $this->_controller . '_' . $this->_mode . '_form'

was not a valid block class. Without knowing what you're trying to do, I'd suggest

public function __construct()
{
    $this->_objectId = 'id';
    $this->_blockGroup = 'brands';
    $this->_controller = 'adminhtml_example';
    $this->_mode = 'edit';    
    parent::__construct();

and ensuring you have a block class for the alias

brands/adminhtml_example_edit_form
//from
//$this->_blockGroup . '/' . $this->_controller . '_' . $this->_mode . '_form'

which will, most likely be a class named

class Desbest_Brands_Block_Adminhtml_Example_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
    //...
}

Problem

It's all coming from `parent::__construct();` Fatal error: Call to a member function setData() on a non-object in /home/desbest/public_html/clients/magentofull/app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php on line 129 ``` <?php class Desbest_Brands_Block_Adminhtml_Brand_Edit extends Mage_Adminhtml_Block_Widget_Form_Container { public function __construct() { parent::__construct(); $this->_objectId = 'id'; $this->_blockGroup = 'brands'; $this->_controller = 'adminhtml_example'; $this->_mode = 'edit'; $this->_addButton('save_and_continue', array( 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'), 'onclick' => 'saveAndContinueEdit()', 'class' => 'save', ), -100); $this->_updateButton('save', 'label', Mage::helper('brands')->__('Save Example')); $this->_formScripts[] = " function toggleEditor() { if (tinyMCE.getInstanceById('form_content') == null) { tinyMCE.execCommand('mceAddControl', false, 'edit_form'); } else { tinyMCE.execCommand('mceRemoveControl', false, 'edit_form'); } } function saveAndContinueEdit(){ editForm.submit($('edit_form').action+'back/edit/'); } "; } public function getHeaderText() { if (Mage::registry('example_data') && Mage::registry('example_data')->getId()) { return Mage::helper('brands')->__('Edit Example "%s"', $this->htmlEscape(Mage::registry('example_data')->getName())); } else { return Mage::helper('brands')->__('New Example'); } } } ```

Original source