Magento,覆盖自定义模块adminhtml块

时间:2014-08-12 09:01:27

标签: php magento override block admin

我正在尝试覆盖自定义模块adminhtml块。该块是一个adminhtml选项卡/表单块。

如果我正确重写,我在beforeHtml()函数中从关联的tabs.php块中得到错误。

继承我认为可以改写的代码:

   <blocks>
        <devaf>
            <class>Dev_Affil_Block</class>
        </devaf>
        <affiliateplus>
            <rewrite>
                <adminhtml_account_edit_tab_form>
                    Dev_Affil_Block_Adminhtml_Account_Edit_Tab_Form
                </adminhtml_account_edit_tab_form>
            </rewrite>
        </affiliateplus>
    </blocks>

实际错误是:

    20  3.5764  29562296    Mage_Core_Block_Abstract->toHtml( ) ..\List.php:43
    21  3.5767  29562448 Magestore_Affiliateplus_Block_Adminhtml_Account_Edit_Tabs->_beforeToHtml( )    ..\Abstract.php:862


  exception 'Mage_Core_Exception' with message 'Invalid block type: Dev_Affil_Block_Adminhtml_Account_Edit_Tab_Form

我认为错误是在这里引起的...尝试初始化块:

档案:Magestore_Affiliateplus_Block_Adminhtml_Account_Edit_Tabs

   $this->addTab('general_section', array(
        'label'     => Mage::helper('affiliateplus')->__('General Information'),
        'title'     => Mage::helper('affiliateplus')->__('General Information'),
        'content'   =>  $this->getLayout()->createBlock('affiliateplus/adminhtml_account_edit_tab_form')->toHtml(),
    ));

我的自定义表单类,扩展了我试图覆盖/覆盖的类。

 class Dev_Affil_Block_Adminhtml_Account_Edit_Tab_Form extends Magestore_Affiliateplus_Block_Adminhtml_Account_Edit_Tab_Form {

我也试过延长通常的Mage类......这也没有用。

 class Dev_Affil_Block_Adminhtml_Account_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {

我在这个类中有一个调试stmt,一旦我能得到那个stmt输出,我应该没问题。

任何想法/提示?

感谢 小号

1 个答案:

答案 0 :(得分:0)

 <rewrite>
    <class_to_override>
        my_class
    </class_to_override>
 </rewrite>

应该是:

 <rewrite>
    <class_to_override>my_class</class_to_override>
 </rewrite>

它应该扩展:

 Mage_Adminhtml_Block_Widget_Form