0
I am studying about Yii2 and do not have much knowledge of the framework.
I’m having difficulty updating data in the database that are in two different models (Student and Address).
The idea is simple, load the view with the student’s data (which has the address as well, 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']);
}
Picture of the EER:
create is getting it right. I’m just having this question in the update, who to call, how, where and etc...
Yes, exactly! I had succeeded and forgotten the question here rsrs but it’s correct. Obg guy!
– Guilherme Luis