Hi all I am using Cakephp 2.x. I have an Events model(table) and a users model. When an event is saved I need to save the current logged in users id into the event model's user_id field. The code I have tried has been commented. Any ideas? Thanks in advance.
public function add(){
//$this->loadModel('User');
if ($this->request->is('post')) {
$this->Event->create();
//$this->request->data['Event']['user_id'] = $this->request->data['User']['id'];
//$this->request->data['Event']['user_id'] = $this->request->data['User']['id'];
if ($this->Event->save($this->request->data)) {
$this->Session->setFlash(__('The event has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The event could not be saved. Please, try again.'));
}
}