这一切都来自 parent::__construct();
致命错误:在第129行的/home/desbest/public_html/clients/magentofull/app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php中的非对象上调用成员函数setData()
<?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');
}
}
}
Run Code Online (Sandbox Code Playgroud)
Ala*_*orm 20
假设您正在处理Magento的纯粹版本,请查看第129行
127: public function getFormHtml()
128: {
129: $this->getChild('form')->setData('action', $this->getSaveUrl());
130: return $this->getChildHtml('form');
131: }
Run Code Online (Sandbox Code Playgroud)
您可以看到尝试获取名为form的子块无法返回对象.最有可能的是,因为在准备布局方法中,Magento无法实例化表单
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();
}
Run Code Online (Sandbox Code Playgroud)
或者因为您的类没有设置以下变量之一
$this->_blockGroup
$this->_controller
$this->_mode
Run Code Online (Sandbox Code Playgroud)
或字符串生成的类别名
$this->_blockGroup . '/' . $this->_controller . '_' . $this->_mode . '_form'
Run Code Online (Sandbox Code Playgroud)
不是一个有效的块类.我不建议你知道你想要做什么
public function __construct()
{
$this->_objectId = 'id';
$this->_blockGroup = 'brands';
$this->_controller = 'adminhtml_example';
$this->_mode = 'edit';
parent::__construct();
Run Code Online (Sandbox Code Playgroud)
并确保您拥有别名的块类
brands/adminhtml_example_edit_form
//from
//$this->_blockGroup . '/' . $this->_controller . '_' . $this->_mode . '_form'
Run Code Online (Sandbox Code Playgroud)
哪个,很可能是一个名为的类
class Desbest_Brands_Block_Adminhtml_Example_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
//...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6669 次 |
| 最近记录: |