在管理員控制器
請參閱editAction
$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'));
然後創建文件名的形式。 php在
應用程序/代碼/社區/命名空間/測試/座/ Adminhtml /測試/編輯/ 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();
}
}
感謝這是工作良好 –