/** * Creates a new group model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Group(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->Id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionCreate() { $model = new Group(); $model->attributes = Yii::$app->request->post(); if ($model->save()) { $this->data['id'] = yii::$app->db->getLastInsertID(); return $this->ok('增加成功'); } }
/** * Creates a new Group model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Group(); $user = new User(); $advisor = new Advisor(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if (!empty(Yii::$app->request->post('id_advisor'))) { $arry = Yii::$app->request->post('id_advisor'); $advisorGroup = new AdvisorGroup(); $advisorGroup->id_group = $model->id_group; foreach ($arry as $key => $value) { $group = clone $advisorGroup; $group->id_advisor = $value; $group->save(); } } return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model, 'advisor' => $advisor, 'user' => $user]); } }
/** * Creates a new Group model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { // if(Yii::$app->request->isAjax) { $model = new Group(); if ($model->load(Yii::$app->request->post()) && $model->save()) { GroupSemesters::createSemestersForGroup($model->getPrimaryKey(), Yii::$app->request->post()['sem_count'], Yii::$app->request->post()['begin_year']); return $this->redirect(['manage']); } else { return $this->renderAjax('create', ['model' => $model]); } //} // else { // throw new NotFoundHttpException('Страница не существует.'); // } }