Example #1
0
 /**
  * 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]);
     }
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEstado()
 {
     return $this->hasOne(EstadoAlumno::className(), ['id' => 'estado_id']);
 }