I am developing an Facebook App using Yii and I’m having trouble populating the Facebook Profile details I extracted from Facebook into another form.
I have the following setup:
User Model -> Extracts the profile detail from Facebook through Graph API
Participate Model -> Will have a form for the users to fill-in the details. When the participate form loads, it should load the Facebook Profile details from User Model.
$model=new Participation;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Participation']))
{
$model->attributes=$_POST['Participation'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,
));
I tried to modify the above code so that it will load the Participate Model with User Model values in the page load. I replaced the $model=new Participation with the following code intending that it will load the values, but it throws an exception.
$model = User::model()->ProfileDetails();
Can anyone help me how I can auto populate the form values of a Model through another Model?