/**
  * 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]);
     }
 }
Exemple #2
0
 public function actionCreate()
 {
     $model = new Group();
     if ($model->load(Yii::$app->request->post())) {
         $model->tag = str_replace('"', '\'', Yii::$app->request->post()['Group']['tag']);
         if (Yii::$app->user->isGuest) {
             Yii::$app->session['groupToSave'] = $model;
             Alert::add(Yii::t('msg', 'Zaloguj się lub zarejestruj, aby dokończyć dodawanie organizacji.'), Alert::TYPE_INFO);
             return $this->redirect(['site/login']);
         }
         if ($model->saveGroup()) {
             //            Alert::add(Yii::t('msg', 'Organization successfully added, now it must be accepted by administrator.'));
             Alert::add('Organizacja została pomyślnie dodana, teraz możesz w swoim panelu edytować stronę organizacji.');
             return $this->goHome();
         }
         Alert::add(Yii::t('msg', 'Something goes wrong, try again or contact us.'), Alert::TYPE_ERROR);
     }
     return $this->render('create', ['model' => $model]);
 }
 public function actionAddGroup($id = null)
 {
     $model = new Group();
     if ($model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->get())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($model->save()) {
             if (!empty($id)) {
                 $advisorGroup = new AdvisorGroup();
                 $advisorGroup->id_group = $model->id_group;
                 $advisorGroup->id_advisor = $id;
                 $advisorGroup->save();
             }
             return true;
         } else {
             return ActiveForm::validate($model);
         }
     }
     return $this->renderAjax('add_group', ['model' => $model, 'id' => $id]);
 }
 /**
  * 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('Страница не существует.');
     // }
 }