Monday, July 30, 2012

How can I Populate my view from belongsTo relationship

I have a controller Users with function Profile

public function profile($id=null){
$log=$this->Auth->User('id'); 
$user = $this->User->UserProfile->find('first',array(
'conditions'=>array('User.id'=>$log),
'recursive'=>1
));
$this->set(compact('user'));
pr($user);
}

I also has a UserProfile Controller

how can i populate my Profile view i accessfully retrieve the data this is my array

Array  (      [UserProfile] => Array          (              [user_id] => 1              [phone] => 552-2947              [mobile] => 09063082315              [fax] => 552-2947              [civil_status] => 1              [nationality] => 1              [birthplace] => Zamboanga City              [birthdate] => 2012-07-27              [sex] =>           )        [User] => Array          (              [id] => 1              [tokenhash] => c484b7b64a68b409ba7d7043bc2b7464a19f4bf7              [active] => 1              [first_name] => Ian              [last_name] => Pansensoy              [middle_name] =>               [email] => vladimirdevonshire@gmail.com              [password] => 0df177a7cba3a96f3a73e8e126837f28e82b3dad              [role_id] => 1              [photo] => /img/users_avatar/2012-07-25-114258staff_image.jpg              [status] => 0              [created] => 2012-07-25 11:42:58              [modified] => 2012-07-27 11:46:34          )   
) 

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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

No comments: