/** * Creates a new Perfil model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Perfil(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Alumno model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $hoy = date('Y-m-d H:i:s'); $perfil = new Perfil(); $perfil->fecha_alta = $hoy; $alumno = new Alumno(); $alumno->estado_id = EstadoAlumno::findOne(['descripcion' => EstadoAlumno::PREINSCRIPTO])->id; // Ver http://www.yiiframework.com/forum/index.php/topic/53935-subforms/page__gopid__248185#entry248185 if ($perfil->load(Yii::$app->request->post()) && Model::validateMultiple([$perfil, $alumno])) { $perfil->save(false); $alumno->perfil_id = $perfil->id; $alumno->save(false); return $this->redirect(['view', 'id' => $alumno->id]); } else { return $this->render('create', ['model' => $alumno, 'perfil' => $perfil]); } }