This is what I would have thought from just looking at the code, too. But it seems that $this->flash(...) does *not* end the execution of the action, and *that's* the problem.
On Thu, Sep 16, 2010 at 10:35 AM, Jeremy Burns | Class Outfit <[email protected]> wrote: > The array('action' => 'index') piece tells the controller to redirect after > setting the flash message. Doesn't it go like this: > > If there is no id, flash invalid user and redirect to the index action. > > If the user is deleted OK, flash successful deletion and redirect to the > index action. > > If we're still here, it's because we had an id but the delete failed. So > flash the failure and redirect to the index action. > > Jeremy Burns > Class Outfit > > [email protected] > http://www.classoutfit.com > > On 16 Sep 2010, at 09:27, psybear83 wrote: > >> Hi all >> >> That's the delete action which Cake baked me: >> >> function delete($id = null) { >> if (!$id) { >> $this->flash(__('Invalid User', true), array('action' >> => 'index')); >> } >> if ($this->User->del($id)) { >> $this->flash(__('User deleted', true), array('action' >> => 'index')); >> } >> $this->flash(__('The User could not be deleted. Please, try >> again.', >> true), array('action' => 'index')); >> } >> >> This results in showing two flashes, "User deleted" AND "The User >> could not be deleted. Please, try again."! IMO there's missing an else >> statement for the last line of the action... >> >> That's not the first time that I thought Cake baked me some pretty bad >> code... Is this normal?? If so, it doesn't really strengthen my trust >> in CakePHP... >> >> Thanks for any reply, Josh >> >> Check out the new CakePHP Questions site http://cakeqs.org and help others >> with their CakePHP related questions. >> >> You received this message because you are subscribed to the Google Groups >> "CakePHP" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] For more options, visit this group at >> http://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
