コード例 #1
0
 /**
  * Creates a new Pregunta model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Pregunta();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id, 'codFormulario' => $model->codFormulario]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
ファイル: PreguntaController.php プロジェクト: rolion/taller1
 /**
  * Creates a new Pregunta model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Pregunta();
     $modelRespuestaExamen = [new RespuestaExamen()];
     $model->load(Yii::$app->request->post());
     $modelRespuestaExamen = DynamicFormModel::createMultiple(RespuestaExamen::className());
     DynamicFormModel::loadMultiple($modelRespuestaExamen, Yii::$app->request->post());
     $valid = $model->validate() && DynamicFormModel::validateMultiple($modelRespuestaExamen);
     if ($valid) {
         $this->negocio->savePregunta1($model, $modelRespuestaExamen);
         $dataProvider = new ActiveDataProvider(['query' => RespuestaExamen::find()->where(['id_pregunta' => $model->id])->orderBy('id')]);
         return $this->redirect(['view', 'id' => $model->id, 'dataProvider' => $dataProvider]);
     } else {
         return $this->render('create', ['model' => $model, 'modelRespuestaExamen' => empty($modelsRespuestaExamen) ? [new RespuestaExamen()] : $modelsRespuestaExamen]);
     }
 }