在我的magento控制器中,我使用了 $ this-> _forward(' edit')但是当我粘贴所有编辑代码时它没有转发到编辑功能功能在这个功能我的功能正常,没有错误。
由于某种原因,_forward功能不转发到编辑功能。
任何一个人都能解决这个问题吗?
以下是我的控制器文件:
<?php
class Gate6Vikas_Testextension_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
protected function _initAction()
{
$this->loadLayout()->_setActiveMenu('testextension/set_time')->_addBreadcrumb('testextension Manager','testextension Manager');
return $this;
}
public function indexAction()
{
$this->_initAction();
$this->renderLayout();
}
public function editAction()
{
$testId = $this->getRequest()->getParam('id');
$testModel = Mage::getModel('testextension/testextension')->load($testId);
if ($testModel->getId() || $testId == 0)
{
Mage::register('test_data', $testModel);
$this->loadLayout();
$this->_setActiveMenu('testextension/set_time');
$this->_addBreadcrumb('testextension Manager', 'testextension Manager');
$this->_addBreadcrumb('Testextension Description', 'Testextension Description');
$this->getLayout()->getBlock('head')
->setCanLoadExtJs(true);
$this->_addContent($this->getLayout()
->createBlock('testextension/adminhtml_testextension_edit'))
->_addLeft($this->getLayout()
->createBlock('testextension/adminhtml_testextension_edit_tabs')
);
$this->renderLayout();
}
else
{
Mage::getSingleton('adminhtml/session')
->addError('Test does not exist');
$this->_redirect('*/*/');
}
}
public function newAction()
{
$this->_forward('edit');
}
public function saveAction()
{
if ($this->getRequest()->getPost())
{
try {
$postData = $this->getRequest()->getPost();
$testModel = Mage::getModel('testextension/testextension');
if( $this->getRequest()->getParam('id') <= 0 )
$testModel->setCreatedTime(
Mage::getSingleton('core/date')
->gmtDate()
);
$testModel
->addData($postData)
->setUpdateTime(
Mage::getSingleton('core/date')
->gmtDate())
->setId($this->getRequest()->getParam('id'))
->save();
Mage::getSingleton('adminhtml/session')
->addSuccess('successfully saved');
Mage::getSingleton('adminhtml/session')
->settestData(false);
$this->_redirect('*/*/');
return;
} catch (Exception $e){
Mage::getSingleton('adminhtml/session')
->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')
->settestData($this->getRequest()
->getPost()
);
$this->_redirect('*/*/edit',
array('id' => $this->getRequest()
->getParam('id')));
return;
}
}
$this->_redirect('*/*/');
}
public function deleteAction()
{
if($this->getRequest()->getParam('id') > 0)
{
try
{
$testModel = Mage::getModel('testextension/testextension');
$testModel->setId($this->getRequest()
->getParam('id'))
->delete();
Mage::getSingleton('adminhtml/session')
->addSuccess('successfully deleted');
$this->_redirect('*/*/');
}
catch (Exception $e)
{
Mage::getSingleton('adminhtml/session')
->addError($e->getMessage());
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
}
}
$this->_redirect('*/*/');
}
}
?>
谢谢