Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Thanks for the push! The correct line of code should read: $this->Comment->set('post_id', $postid); Commented Jun 3, 2010 at 23:52
  • Only if you are pushing it from your COmments controller out to your view. When dealing with posted data in your controller, it's all accessible from $this->data so you can just overwrite values directly if need be. Commented Jun 4, 2010 at 13:37
  • I was a bit premature in thinking I had fixed the problem. I was able to store values using both the method you recommend and through a couple other ways IF i am writing out a string ($this->Comment->post_id ='1';). If i use the $postid variable a 0 gets written to the post_id field of my comments table entry. Any thoughts? I can use print_r and see that $postid is what I've passed in to the add function. Any thoughts? Commented Jun 6, 2010 at 13:28
  • Where are you doing your print_r() also you can use pr() Cake shorthand instead. Sounds like your variable isn't being passed Commented Jun 7, 2010 at 11:00
  • I've edited my original post to show my current code. I'm doing my print_r() as the last line of my add method. Does add get called more than once? Once when I goto my add page and once again when I post my form data? Commented Jun 8, 2010 at 2:13