I'm trying to achieve a thank you page after submitting a form in Zend 1.12
in the index i have form and i want if the validation passes then should go to another view (NOT INDEX) for thank you page. how can i do this in my code:
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;
}
and after that where should i create the .phtml file? in the application\views\scripts\index?
I think you're looking for render:
$this->view->render('index/yourotherview.phtml');
In this case, index/
is referring to your views/scripts/index
folder, and the yourotherview.phtml
file.
So, all together it would be:
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;
}
EDIT:
From your comment it looks like you just want to be redirected instead of displaying a different view. In this case, it's as easy as creating a new action and making the view for it:
public function resultAction() {
// Code here if you need it
}
Then create the file result.phtml
in the index/
views directory, and you'll need $this->_redirect('/index/result');
in the index controller. (See above code)