Tuesday, July 28, 2009

Re: using simple HTML form with cakePHP !

hi,
you have to name your input right to get the data into $this->data. e.g.

<input type="text" name="data[Comment][e_mail]" id="e_mail" />

greets
Andreas

Abraham Boray schrieb:
> I'm not usin' Form helper 4 some reason , and I'm working with a
> simple comment form ::
>
>
> /**********form*************/
> <form action="" method="get" name="CommentForm" id="CommentForm">
> <input name="username" type="text" id="username" />
> <input type="text" name="e_mail" id="e_mail" />
> <input type="text" name="a_url" id="a_url" />
> <textarea name="content" id="content" rows="5"></textarea>
> <input name="CommentItBtn" id="CommentItBtn" type="button"
> class="button" value="Comment" />
>
>
> ///////*************My Model(Table) ,Fields names
> are ::********///////
>
> -id
> -post_id
> -content
> -a_url
> -e_mail ...
>
> ////*************And I'm doing an ajax
> call ::*********************/////
>
> var data=$('#CommentForm').formSerialize();
> //I'm using a Form plugins to retrieve data from the form
> eg:e_mail=ab@cf.ma&....
>
> $.ajax({
> type: "POST",
> url: "comments/AddComment/",
> data: data,
> success: function(msg){
> alert( "Data status: " + msg );
> }
> });
>
> /*******controller action==> AddComment ******//
> function AddComment(){
>
> $this->layout = 'ajax';
>
> if ($this->RequestHandler->isAjax()) {
> if ($this->Comment->save($this->data)) {
> echo 'success';
> }
>
> Configure::write('debug', 0);
> $this->autoRender = false;
> exit();
> } }
>
>
> The comment is not saved !! ,and I get no error ,I dnt get even the "
> echo 'success';" of the action !
> Firebug indicat that there is no error ,and the ajax call is
> performed !
>
> Thanks in advance , I hope find a solution
> Regards
> Abraham
>
>
>
>
> >
>
>


--~--~---------~--~----~------------~-------~--~----~
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: