What do I have to change on the cake side of things to get this
working? Currently it's just set up for non-ajax submission, but I
figured submitting the data using ajax would yield the same results.

The form appears on posts/view and submits to comments/add, which
saves the form if it validates. If it invalidates, it stores the
validation info into a session and redirects back to posts/view where
the error messages are outputted (form helper).

Here's my current code:

posts/view:

        function view($slug = NULL)
        {
                if($slug == NULL)
                {
                        $this->redirect('/posts');
                }
                //Find post by slug.
                $this->set('data', $this->Post->findBySlug($slug));
        }

comments/add:

        function add()
        {
            if (!empty($this->data))
            {
                if ($this->Comment->save($this->data))
                {
                    $this->Session->setFlash('The Comment has been
saved', $layout = 'flash_success');
                }
                else
                {
                    $this->_persistValidation('Comment');
                    $this->Session->setFlash('The Comment could not be
saved. Please correct the errors and try again.', $layout =
'flash_error');
                }
            }
            $this->redirect($this->referer(), null, true);
        }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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