/** * Creates a new DisciplinaPeriodo model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new DisciplinaPeriodo(); $model->scenario = 'default'; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { $lista = Disciplina::find()->all(); foreach ($lista as $l) { $l->nomeDisciplina = $l->codDisciplina . ' - ' . $l->nomeDisciplina; } $arrayDisciplinas = ArrayHelper::map($lista, 'id', 'nomeDisciplina'); return $this->render('create', ['model' => $model, 'arrayDisciplinas' => $arrayDisciplinas]); } }
/** * Creates a new DisciplinaPeriodo model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new DisciplinaPeriodo(); $model->scenario = 'default'; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { //if ($model->errors) { // //Yii::$app->getSession()->setFlash('danger', $this->convert_multi_array($model->errors)); // foreach ($model->getErrors() as $key => $value) { // Yii::$app->getSession()->setFlash('danger', $key.' - '.$value); // } // foreach (Yii::$app->session->getAllFlashes() as $key => $message) { // echo '<div class="alert alert-' . $key . '" role="alert">' . $message . '</div>'; // } //} else { return $this->render('create', ['model' => $model]); //} } }