Tuesday, May 22, 2012

Re: How to redirect two pages back?

I created the following in my controller, just setReferer when you want to track where you want to go back to.

function origReferer(){
return $this->Session->read('referer');
}
function setReferer(){
$this->Session->write('referer', $this->referer());
}

eg:
function edit($id){
    if (empty($this->request->data)) {
        $this->request->data = $this->ModelToEdit->read(null, $id);
$this->setReferer();
    }
}

On Sunday, April 15, 2012 2:15:20 PM UTC-6, Daniel wrote:
I am using the following code to go back a page, but the problem is
that the action is an "add" one so it just goes back to an empty "add"
form:

if ($this->request->is('post')) {
        // blah blah ...
        if ($this->Inemail->save($this->request->data)) {
                // blah blah ...
                $this->redirect($this->referer());

I think what I need to do is go back two pages.  Is this possible?

Thanks.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: