两步做你想做的事:
(请注意大小写)
1- 更新 adminhtml Block 类
- 打开 app/local/[YourNamespace]/[YourModule]/Block/Adminhtml/[YourModule]/Grid.php
-
在类声明中改变:
class [YourNamespace]_[YourModule]_Block_Adminhtml_[YourModule]_Grid extends Mage_Adminhtml_Block_Widget_Grid
到
class [YourNamespace]_[YourModule]_Block_Adminhtml_[YourModule]_Grid extends Mage_Adminhtml_Block_Widget_Form_Container
-
然后清除文件的所有内容(方法)并替换为:
public function __construct() {
parent::__construct();
$this->setTemplate('[yourmodule]/[some-template-filename].phtml');
$this->setId('[some_id]');
}
2- 创建您的模板文件
创建 app/design/adminthml/default/default/template/[youmodule]/[some-template-filename].phtml
您会通过深入研究其他 Magento 模块来找到想法和灵感,但这里有一些起点:
<div class="content-header">
<table cellspacing="0" class="grid-header">
<tr>
<td><h3><?php echo $this->__('A nice title'); ?></h3></td>
<td class="a-right">
<button onclick="history.go(-1)" class="scalable back" type="button"><span><?php echo $this->__('Cancel'); ?></span></button>
<button onclick="editForm.submit()" class="scalable save" type="button"><span><?php echo $this->__('Save'); ?></span></button>
</td>
</tr>
</table>
</div>
<div class="entry-edit">
<form id="edit_form" name="edit_form" method="post" action="YOUR JOB TO CALL THE RIGHT CONTROLLER">
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Another nice title')?></h4>
<fieldset id="my-fieldset">
<table cellspacing="0" class="form-list">
<tr>
<td class="label"><?php echo $this->__('A nice TD title'); ?> <span class="required">*</span></td>
<td class="label required-entry">
CONTENT FOR YOUR TD
</td>
</tr>
</table>
</fieldset>
</form>
</div>
<script type="text/javascript">
var editForm = new varienForm('edit_form');
</script>
以上所有内容都应该指导您想要实现,但只要您不使用通常通过单击由 Module Creator 生成的“常规”网格的某行提供的项目编辑,一个完整的工作台Module Creator 创建的代码、文件和文件夹现已过时。
我最好的选择是从头开始制作自己的模块:)