hi! i have a problem in my actionUpdate and loadmodel function when i update a form with relations. There is no problem with my actioncreate. The loadmodel should point to all related tables.
public function actionUpdate($id)
{
$model = $this->loadModel($id);
$account = $this->loadModel($id);
$student = $this->loadModel($id);
$faculty = $this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Patron']))
{
$model->attributes=$_POST['Patron'];
if($model->save())
$this->redirect(array('view','id'=>$model->Patron_ID));
}
$this->render('update',array(
'model'=>$model,
'account'=>$account,
'student'=>$student,
'faculty'=>$faculty,
));
}
public function loadModel($id)
{
$model=Patron::model()->with('PatronAccount')-with('Student')->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
sorry i’m just new to yii.