Saturday, July 4, 2009

Re: Automagically filling table-fields?

>> > This is my PostsController::add():
>> >        function add() {
>> >                        if (!empty($this->data)) {
>> >                                $this->data['Posts']['username'] = $this->Auth->user
>> > ('username');
>> >                        if  ($this->Post->save($this->data)) {
>> >                                $this->Session->setFlash('Your robot has been saved.');
>> >                                $this->redirect(array('action' => 'index'));
>> >                        }
>> >                }
>> >        }
I think you should place
$this->data['Post']['username'] = $this->Auth->user
after the post->save...

--
pietro

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