我在Zend 1.12
中提交表单后试图获得一个感谢页面在索引中我有表单,我想如果验证通过然后应该转到另一个视图(NOT INDEX)谢谢页面。我怎么能在我的代码中这样做:
public function indexAction()
{
// action body
$C_form = new Application_Form_Eform();
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($C_form->isValid($formData)) {
$this->_helper->redirector('','result');
exit;
} else {
$C_form->populate($formData);
}
}
$this->view->form = C_eform;
}
之后应该在哪里创建.phtml文件?在application \ views \ scripts \ index?
中答案 0 :(得分:1)
我认为您正在寻找render:
$this->view->render('index/yourotherview.phtml');
在这种情况下,index/
指的是您的views/scripts/index
文件夹和yourotherview.phtml
文件。
所以,它们一起将是:
public function indexAction()
{
// action body
$C_form = new Application_Form_Eform();
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($C_form->isValid($formData)) {
$this->_redirect('/index/result);
} else {
$C_form->populate($formData);
}
}
$this->view->form = C_eform;
}
修改强>
从您的评论中看起来您只是想重定向而不是显示不同的视图。在这种情况下,它就像创建新动作并为其创建视图一样简单:
public function resultAction() {
// Code here if you need it
}
然后在result.phtml
views目录中创建文件index/
,在索引控制器中需要$this->_redirect('/index/result');
。 (见上面的代码)