Hi, Here I am sending you my two files. view and controller.
Please lemme know what is the best way. Thanks, Jayanand Bhushi On Wed, Dec 9, 2009 at 12:23 PM, John Andersen <[email protected]>wrote: > Are you using $_POST to fill out your view? > Please show the code from your view and/or elements that your present! > Enjoy, > John > > On Dec 8, 11:07 pm, Andrei BOGDAN <[email protected]> > wrote: > > Hello, > > My add action in comments_controller looks like this now: > > [code] > > function add() { > > if (!empty($this->data)) { > > if ($this->Comment->save($this->data)) { > > $comments = $this->Comment->find('all', > array('conditions' => > > array('post_id' => $this->data['Comment']['post_id']), 'recursive' => > > -1)); > > unset($this->data['Comment']); > > $this->data = $this->Comment->create(); > > $this->set(compact('comments')); > > $this->render('add_succes','ajax'); > > } else { $his->render('add_failure','ajax');} > > } > > } > > [/code] > > I used with firebug to debug the app and I saw that when I render > > 'add_succes' $_POST keeps the old values instead of clearing them. > > > > - > > Andrei Bogdan > > > > 2009/12/8 John Andersen <[email protected]>: > > > > > Ok, sorry, didn't see you were using the $this->data variable later > > > inside the if statement, so please move the statement: > > > > > $this->data = $this->Comment->create(); > > > > > after your find statement. The find statement uses the data from the > > > $this->data variable! > > > > > Tell us if the above fixes your problem, or what Chickenhen wrote did! > > > Enjoy, > > > John > > > > > On Dec 7, 10:00 pm, Andrei BOGDAN <[email protected]> > > > wrote: > > >> I've change my code and the add action from comments controller looks > like this: > > >> [code] > > >> function add() { > > >> if (!empty($this->data)) { > > >> if ($this->Comment->save($this->data)) { > > >> $this->data = $this->Comment->create(); > > >> $comments = $this->Comment->find('all', > array('conditions' => > > >> array('post_id' => $this->data['Comment']['post_id']), 'recursive' => > > >> -1)); > > >> $this->set(compact('comments')); > > >> $this->render('add_succes','ajax'); > > >> } else { $his->render('add_failure','ajax');} > > >> } > > >> } > > >> [/code] > > > [snip] > > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help > others with their CakePHP related questions. > > > > > 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]<cake-php%[email protected]>For > > > more options, visit this group athttp:// > groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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]<cake-php%[email protected]>For > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
add.ctp
Description: Binary data
<<attachment: users_controller.php>>
