Friday, August 28, 2009

Re: $ajax->form - NOT WORKING!!!!! ARGHHHH

Try the following code for your ajax form. Note the update to
'comments' from 'comment'::

<?php
echo $ajax->form(null,'post',array(
'update'=>'comments',
'url'=>array(
'controller'=>'comments',
'action'=>'add'
)
)
);
echo $form->input('Comment.name');
echo $form->input('Comment.content');
echo $form->input('Comment.post_id',array
('type'=>'hidden','value'=>$post['Post']['id']));
echo $form->end('Add Comment');
?>

On Aug 24, 3:45 pm, yaronh <yaron.har...@gmail.com> wrote:
> Hi,
>
> I have the same problem, did anyone found a solution for it?
>
> On Jul 23, 12:24 am, David <d...@kabaddle.com> wrote:
>
>
>
> > Hello,
>
> > I am trying to work withajaxhelper to do a commentsformon a test
> > blog system.
> > I am fairly new...but have managed to pick most things up...but this
> > is doing my head in!
>
> > Okay so I show a blog post and people can comment on them so I use
> > this in the view file:
>
> > <?php echo $ajax->form(null,'post',array
> > ('update'=>'comment','url'=>array
> > ('controller'=>'comments','action'=>'add')));
> >  ?>
> > <?php echo $form->input('Comment.name'); ?>
> > <?php echo $form->input('Comment.content'); ?>
> > <?php echo $form->input('Comment.post_id', array
> > ('type'=>'hidden','value'=>$post['Post']['id'])); ?>
> > <?php echo $form->end('Add Comment'); ?>
>
> > -------
> > then the logic for this in the Comments controller / add function is :
>
> > function add() {
> >                 if(!empty($this->data)){
> >                         $this->Comment->create();
> >                         if($this->Comment->save($this->data)) {
> >                                 $comments=$this->Comment->find('all',array('conditions'=>array
> > ('post_id'=>$this->data['Comment']['post_id']),'recursive'=>-1));
> >                                 $this->set(compact('comments'));
> >                                 $this->render('add_success','ajax');
> >                         }else{
> >                                 $this->render('add_failure','ajax');
> >                         }
> >                 }
> >         }
>
> > ..........now it all displays good......BUT when I click 'Add Comment'
> > It doesnt do ANYTHING!!!!!!!!!!! I have searched high and low and
> > cannot find any help on the web, so I am hoping some superstar on here
> > can help??
>
> > WHY is it not doing ANYTHING....atleast if I got an error I could take
> > it from there, but I get NOTHING!
>
> > PLEASE HELP!!!!!!!!!!
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: