I'm studying on Yii2 and I do not have much knowledge of the framework.
I'm having trouble updating database data in two different models (Student and Address).
The idea is simple, load the view with the student data (which has the address also, but there is an address-only model).
Student Update (Controller):
public function actionUpdate($id){
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('update', [
'model' => $model,
]);
}
In the Student model I have the following method:
public function getEndereco0(){
return $this->hasOne(Enderecos::className(), ['id' => 'endereco']);
}
EER image:
The create is picking up right. I just have this doubt in the update, who to call, how, where and etc ...