Thanks for your answer but it is still not working.
When I view the generated HTML code, the tag <form id="...."> is not
there. Therefore I can't submit the form.

Your tip to $this->render was very useful though ;) (now it makes
sense)

Hugo

On 19 Abr, 05:21, adallas <[email protected]> wrote:
> I used the same example you did and made the same mistake. The 2nd
> argument to $ajax->form is the model, not the form method. Instead of
> 'post', you need your model name (author?) there.
>
> Also, I don't think you need $ajax->submit. $form->end('Add') does the
> right thing.
>
> Your controller looks fine. I didn't initially understand what the 2nd
> arg to $this->render('view','ajax') did, but it's easy to find in the
> code. The 2nd arg is the layout, so instead of default.ctp, which
> presumably has your page frame and navigation, it uses ajax.ctp, which
> has exactly nothing around your view.
>
> Glad I could help.
>
> /alastair/
>
> On Apr 18, 7:28 am, hugocaracol <[email protected]> wrote:
>
> > I'm creating an ajax form but it's not working and I can't figure out
> > why.
>
> > The view to the ajax form is:
>
> > $ajax->form('/authors/add','post',array('url' => '/authors/add',
> > 'update'=>'DivAddAuthor'));
> > $form->input('name');
> > $ajax->submit('Add', array('url' => '/authors/add',
> > 'update'=>'DivAddAuthor'));
> > $form->end();
>
> > I have the helpers defined in the controller
>
> > var $helpers = array('Html', 'Form','Ajax','Javascript');
>
> > And the controller code is:
>
> >         function add() {
> >                 if (!empty($this->data)) {
> >                         $this->Author->create();
> >                         $this->Author->save($this->data);
> >                 }
> >                 $this->render('add','ajax');
> >         }
>
> > Could you help me? Am I missing something?
>
> > Hugo
--~--~---------~--~----~------------~-------~--~----~
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