Example #1
0
 /**
  * Creates a new Tags model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  * @throws ForbiddenHttpException
  */
 public function actionCreate()
 {
     $model = new Tags();
     // Check RBAC Permission
     if ($this->userCanCreate()) {
         if ($model->load(Yii::$app->request->post())) {
             // If alias is not set, generate it
             if ($_POST['Items']['alias'] == "") {
                 $model->alias = $model->generateAlias($model->title);
             }
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->id]);
             } else {
                 return $this->render('create', ['model' => $model]);
             }
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         throw new ForbiddenHttpException();
     }
 }