Magneto,管理员表单已填写两次

时间:2018-07-14 17:17:20

标签: magento layout admin

我之前制作了一个Magento Admin表单,还可以。但是在this tutorial的帮助下,我向其中添加了标签。但是在HTML输出中,我有两个表单标签。一个具有表单和表单密钥的内容,另一个仅具有表单密钥。

问题是company_Vendor_Block_Adminhtml_Vendor_Edit_Form._prepareForm()运行了两次。因此它有两种形式,我认为,由于vendorController.EditAction()

中的这一行,它运行了两次
$this->_addContent($this->getLayout()->createBlock('vendor/adminhtml_vendor_edit'))
    ->_addLeft($this->getLayout()
      ->createBlock('vendor/adminhtml_vendor_edit_tabs'));

当我只有createBlock('vendor/adminhtml_vendor_edit')时,此命令仅运行一次,但是当我向左添加选项卡时,它将运行两次。 我该如何解决?

注意:我的代码与the tutorial完全相同。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。 问题是关于一个额外的(无用的)XML布局文件。因此renderLayout()做一个额外的表单。可以通过从布局中删除XML文件或仅转换

来解决问题。
 $this->_addContent($this->getLayout()->createBlock('vendor/adminhtml_vendor_edit'))->_addLeft($this->getLayout()->createBlock('vendor/adminhtml_vendor_edit_tabs'));

$this->_addLeft($this->getLayout()->createBlock('vendor/adminhtml_vendor_edit_tabs'));