我的目标是将表单放入表单容器。当我在控制器中直接调用表单时,它可以工作,但是当我调用容器时,会出现以下问题:
致命错误:在第144行的app / code / core / Mage / Adminhtml / Block / Widget / Form / Container.php中以布尔值调用成员函数setData()
代码行是:
public function getFormHtml() {
$this->getChild('form')->setData('action', $this->getSaveUrl());
return $this->getChildHtml('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();
}
我尝试调整_blockGroup
,_controller
和_mode
的值,但无济于事...
我的表单容器类:
class Cheek_Portraits_Block_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
public function __construct()
{
$helper = Mage::helper('portraits');
$this->_blockGroup = 'portraits';
$this->_controller = 'page';
$this->_mode = 'edit';
if($this->getRequest()->getParam('id'))
{
$this->_headerText = $helper->__('Edit')." portrait";
}
else
{
$this->_headerText = $helper->__('New')." portrait";
}
parent::__construct();
}
}
这是我的文件夹和文件:
我也尝试过这样: