Sunday, June 2, 2013

Re: $this->redirect not working

if there is NO redirect at all you probably echo sth too soon and therefore headers are already sent and your redirect cannot work anymore . Please check the files inside app/controller, make sure all php files do not have closing ?>

On Sunday, March 11, 2012 9:54:30 AM UTC+8, Brian Bowler wrote:
So I have this function where the user can add the weight to materials and save them. However after the updateAll, $this->redirect doesn't work at all and the result shows up with a blank page with nothing in the source. In an ideal world I would have it redirect to a different page but at a minimum I would like it to go back to the page where they entered in the weights.
 
  public function instructions($id = null) {
        $instructions = $this->Formula->findFormula($id);
        $count = count($instructions);
        $this->set(array('instructions' => $instructions, 'count' => $count, 'formulaId' => $id));
        if(!empty($this->data)) {
            $count = count($this->request->data);
            for($i = 0; $i <= $count; $i++) {
                $this->Formula->updateAll(
                    array('Formula.weight' => $this->request->data['Formula'][$i]['weight']),
                    array('Formula.id' => $this->request->data['Formula'][$i]['id'])
                );
            }
        }
        $this->redirect(array('controller' => 'instructions', 'action' => 'instructions', $id));
    }

I have no idea what causes this. Any help is much appreciated, even if its just telling me where in the manual to read up on it.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: