0

我正在开发 Magento 社区版 1.7 版本。当我从该网格中单击“添加新”时,我在管理员中有一个网格,会出现一个表单,但左侧有一些选项卡。我需要删除该选项卡并且只需要表单。

http://d.pr/i/Qa8i

app/code/community/namespace/test/Block/Adminhtml/test/Edit/Tabs.php

我在上面文件中的标签代码是:

 protected function _beforeToHtml() {

    $this->addTab('form_section', array(
        'label' => Mage::helper('test')->__('Book'),
        'title' => Mage::helper('test')->__('Book'),
        'content' => $this->getLayout()->createBlock('test/adminhtml_book_edit_tab_form')->toHtml(),
    ));

    return parent::_beforeToHtml();         
}

任何人都可以解决这个问题吗?

4

2 回答 2

3

在您的管理控制器中

请参阅编辑操作

$this->_addContent($this->getLayout()->createBlock('<module>/adminhtml_<module>_edit'))
                     ->_addLeft($this->getLayout()->createBlock('<module>/adminhtml_<module>_edit_tabs'));

消除

->_addLeft($this->getLayout()->createBlock('<module>/adminhtml_<module>_edit_tabs'));

然后在中创建文件名 form.php

app/code/community/namespace/test/Block/Adminhtml/test/Edit/Form.php

并将代码粘贴到

class <Namespace>_<Module>_Block_Adminhtml_<Module>_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
    {
        $<module>Form = new Varien_Data_Form(array(
            'id' => 'edit_form',
            'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
            'method' => 'post',
        ));
        $<module>Form->setUseContainer(true);
        $this->setForm($<module>Form);

        $fieldset = $<module>Form->addFieldset('<module>_form', array(
            'legend'      => Mage::helper('<module>')->__('Item Information'),
            'class'       => 'fieldset-wide',
            )
        );

        $fieldset->addField('<module>_name', 'text', array(
            'label'     => Mage::helper('<module>')->__('Name'),
            'class'     => 'required-entry',
            'required'  => true,
            'name'      => 'name',
        ));


        if ( Mage::getSingleton('adminhtml/session')->get<Module>Data() )
        {
          $<module>Form -> setValues(Mage::getSingleton('adminhtml/session')->get<Module>Data());
          Mage::getSingleton('adminhtml/session')->get<Module>Data(null);
        } elseif ( Mage::registry('<module>_data') ) {
          $<module>Form-> setValues(Mage::registry('<module>_data')->getData());
        }
        return parent::_prepareForm();
    }
}
于 2013-12-20T06:57:11.667 回答
0

你好,检查下面的路径app/code/community/namespace/yourmodule/Block/Adminhtml/yourmodule/Edit/Tabs.php 检查函数 _beforeToHtml() 和 __construct()。评论你想要的

希望这对你有帮助

于 2013-12-20T06:25:06.893 回答