Wednesday, March 30, 2011

redirect after delete not working

My delete method don't redirect after execution.

The record is deleted but the redirect doesn't occur. If I reload the
page, the flash message appears and the record is not there anymore.

It used to work and I can´t find why that stopped working. I tried
setting debug to 0 and 1 without any more success.

I'm using Cake 1.3.7 and testing in Firefox and Chrome.

function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('invalid.', true), 'flash_message',
array('msgclass'=>'error'));
$this->redirect(array('action'=>'index'));
}
if ($this->MaterialQuantity->delete($id)) {
$this->Session->setFlash(__('deleted', true), 'flash_message',
array('msgclass'=>'confirmation'));
$this->redirect(array('action'=>'index'));
}
$this->Session->setFlash(__('not deleted', true), 'flash_message',
array('msgclass'=>'error'));
$this->redirect(array('action' => 'index'));
}

--
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: