0
Hello Everyone I am starting in yii2, and I have a question I am making a form in which I insert two different models in a single form, but I am not able to perform create: Follow the code I made:
public function actionCreate()
{
$model = new Inscrito();
$modelEmpresa = new Empresa();
if ($model->load(Yii::$app->request->post()) && $model->load(Yii::$app->request->post()) && $modelEmpresa->save() && $modelEmpresa->save())
{
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
'modelEmpresa' => $modelEmpresa,
]);
}
}
Why aren’t you getting it? What mistake?
– Marcelo de Andrade