Share on Google+Share on Google+

ZF Page Redirect

Advertisement
It is one of the most common activity in a web application to redirect one web page to another web page. We will learn how to redirect page in Zend Framework form...

Redirect to another page using submit button, in ZF:

It is one of the most common activity in a web application to redirect one web page to another web page. We will learn how to redirect page in Zend Framework form. As we have already discussed how to create forms in Zend Framework in the early tutorials we will skip that part.

Now let's assume that we have to actions (pages) in the IndexController, redirect and link, and we have created a form as below:

ZF-Form 

Now we need to create a link between the redirectAction and linkAction, to do so we need to work on the submit button. It will be a mess if we do not move forward carefully or without getting things properly, so let's start one by one:

So, what's new in the submit button? It is just another simple button, if you are thinking in this way, sorry it is not just another submit button, because in ZF the submission process is quite different. How? let me explain:

Add the following code in the redirectAction() method:

if($this->getRequest()->isPost()){

$this->_helper->redirector('link');

}

 Let's Consider the other linkAction method has the following coding:

public function linkAction()

{

// action body

$this->view->title="Link";

$this->view->headTitle("Linking Page");

}

and in the link.phtml we just mention a little gesture Hi, so the output will be as follows:

link

In the next section we will learn how to send data from one page to another.

Advertisements

Posted on: April 29, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.