1.
controller
public function editAction(){
$id = $this->getRequest()->getParam('id');
$model = Mage::getModel('blog/blog')->load($id);
if($model->getId() || $id ==0){
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
if(!empty($data)){
$model->setData($data);
}
Mage::register('gao_data',$model);
$this->loadLayout();
//$this->setActiveMenu('TerryTest11/Bao');
$this->_addContent($this->getLayout()->createBlock('gao/manage_gao_edit') )
->_addLeft($this->getLayout()->createBlock('gao/manage_gao_edit_tabs'));
$this->renderLayout();
}else{
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('blog')->__('Post does not
exist'));
$this->_redirect('*/*/');
}
2.
然后再new那个功能块的
AQ/Gao/Block/Manage/Gao/Edit/Tab/Form.php
AQ/Gao/Block/Manage/Gao/Edit/Tab/Options.php
在protected function _prepareForm()方法里面加上。
if ( Mage::getSingleton('adminhtml/session')->getGaoData() )
{
$form->setValues(Mage::getSingleton('adminhtml/session')->getGaoData());
Mage::getSingleton('adminhtml/session')->setGaoData(null);
} elseif ( Mage::registry('gao_data') ) {
$form->setValues(Mage::registry('gao_data')->getData());
}