Hi,
I want to update a record using two models but I’m getting this error when trying to do just that:
My actionUpdate in the controller:
public function actionUpdate($id)
{
$this->layout = 'detail';
$model = $this->findModeltwo($id);
$modelGpcc = GPCCCAMPAIGNS::findOne($id);
$modelSat = CAMPDETALLENOTIFICACIONESSAT::findOne($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$modelSat->CODIGO = $model->CODIGO;
if ($modelSat->load(Yii::$app->request->post()) && $modelSat->save()){
$session = Yii::$app->session;
Yii::$app->session->setFlash('kv-detail-success', 'Datos guardados con éxito!');
return $this->redirect(['view', 'id' => $model->id]);
}
} else {
return $this->render('update', [
'model' => $model,
'modelGpcc' => $modelGpcc,
'modelSat' => $modelSat,
]);
}
}
and protected function findmodeltwo
protected function findModeltwo($id)
{
if (($model = CAMPDETALLENOTIFICACIONES::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
I really don’t know what to do for this to work