o, ok. Thanks brian. i think thats a pattern im going to be using
heaps, so much appreciated.

will

On Aug 27, 2:19 am, brian <[email protected]> wrote:
> In CommentsController::add() do something like this:
>
> if ($this->Comment->validates())
> {
>         if ($this->Comment->save($this->data))
>         {
>                 ...
>         }
>         else
>         {
>                 ...
>         }}
>
> else
> {
>         $this->Session->setFlash('...');
>         $this->redirect(
>                 array(
>                         'controller' => 'Articles',
>                         'action' => 'view',
>                         $this->data['Comment']['article_id']
>                 )
>         );
>
> }
>
> So, instead of letting Cake call validates() automatically when you
> call save(), you invoke it yourself so as to have some finer control
> over what happens next.
>
> On Wed, Aug 26, 2009 at 5:11 AM, #2Will<[email protected]> wrote:
>
> > Hi all.
> > I have a situation, that must be very common, and i'm wondering what
> > the Cakephp approved way to do it is. I don't really want to just make
> > up a way, because i might lose some of the goodness of following the
> > conventions etc.
>
> > I have a page with an article on it, and want a form to add comments
> > to that article.
>
> > Where do i put the code to proccess the form? by default it goes off
> > to the comments/add method, but then if it fails validation, im not on
> > the article page anylonger.
>
> > should i put the proccessing code in the articles/view  method? it
> > seems to detract from the neatness of it all somehow.
>
> > Iv'e got a feeling im thinking about this in completely the wrong way.
> > so feel free to point that out.
>
> > thanks for any help.
>
> > Will
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to