On Tue, Sep 29, 2009 at 2:23 AM, Cronet <cro...@gmx.de> wrote: > > Hi Brian, > > thanks for your answer. > > That's a neat trick to avoid the switch statement! > > > I've done the redirecting, because i thought it's more DRY. With your > solution (which works perfect!) i need to copy the admin_index method > in the admin_switchStatus method. > (In this particular case, it's only a pagination statement...so no > problem)... > > But what if the logic comes complexer? Should I then move it to the > model?
You know, I didn't event think about the fact you need some actual data! Instead of calling redirect(), try setAction(). The former sends headers to the client to get it to make a new request to the redirected controller/action, while the latter simply redirects within the same request. $this->News->saveField('active', 1 - $news['News']['active']); $this->setAction('admin_index'); Then, put the following inside your admin_index action: if ($this->RequestHandler->isAjax()) { Configure::write('debug', 0); $this->layout = 'ajax'; } That *should* work. AFAIK, the fact you're checking that inside a new action shouldn't make a difference because it's technically the same request. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---