1) make sure TaskNote belongsTo User 2) set $this->Task->recursive = 2;
As a side note, you might want to use the Containable behavior to get more control of the queries. On Sunday, September 8, 2013 12:23:44 PM UTC-4, April DeRossett wrote: > > > <https://lh4.googleusercontent.com/-mrtYQE5nTDA/Uiyjbwgw8CI/AAAAAAAAAEM/F266lPJCSZ4/s1600/CropperCapture%5B1%5D.png> > Can someone point me in the right direction on this? > > I have a tasks table in my application - Tasks can be owned by the person > who creates them or the task can be assigned to another user. Users can > make notes on the task as they work through the task. The tasks care > displayed as in the image -- My problem is with the "3:" in the task note. > I want to display the fullname field of the user who entered the note but I > can't figure out how to return that data. > > *Here is what is in my controller:* > $options = array('OR' => array('Task.user_id =' => > $this->Auth->user('id'),'Task.assigned_id =' => $this->Auth->user('id') )); > $this->set('tasks', $this->Task->find('threaded', > array('conditions' => array('or' => array('Task.user_id =' => > $this->Auth->user('id'), 'Task.assigned_id =' => > $this->Auth->user('id')))))); > * > Here is the output:* > > (int) 0 => array( > 'Task' => array( > 'id' => '1', > 'user_id' => '3', > 'task_name' => 'Test Task', > 'created' => '2013-08-29', > 'due' => '2013-08-31', > 'modified' => '2013-08-29', > 'description' => 'test the task system', > 'task_status_id' => '1', > 'assigned_id' => '4' > ), > 'User' => array( > 'id' => '3', > 'username' => 'april.derossett', > 'created' => '2013-08-08', > 'fullname' => 'April DeRossett' > ), > 'Assigned' => array( > 'id' => '4', > 'username' => 'jim.pryor', > 'created' => '2013-08-14', > 'fullname' => 'Jim Pryor', > ), > 'TaskStatus' => array( > 'id' => '1', > 'name' => 'Active' > ), > 'TaskNote' => array( > (int) 0 => array( > 'id' => '7', > 'task_id' => '1', > * 'user_id' => '3',* > 'note' => 'Second Task Note', > 'created' => '2013-09-08', > 'modified' => '2013-09-08' > ), > (int) 1 => array( > 'id' => '6', > 'task_id' => '1', > *'user_id' => '3',* > 'note' => 'First task note', > 'created' => '2013-09-08', > 'modified' => '2013-09-08' > ) > ), > > I want to return the fullname field from the users table for the id shown > in red. Any ideas? > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
