/**
  * Страница добавления метки.
  *
  * @return string|\yii\web\Response
  */
 public function actionCreate()
 {
     $modelTag = new Tag();
     if ($modelTag->load(Yii::$app->request->post()) && $modelTag->save()) {
         return $this->redirect(['back-tag/view', 'id' => $modelTag->id]);
     }
     return $this->render('/back/tag/create', ['modelTag' => $modelTag]);
 }
Example #2
0
 /**
  * Creates a new Tag model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Tag();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->tag_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #3
0
 /**
  * Creates a new Tag model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Tag();
     if ($model->load(Yii::$app->request->post())) {
         if ($result = $model->save()) {
             $model->setActive();
             return $this->message('标签创建成功', 'success', ['view', 'id' => $model->id]);
         }
         return $this->message(array_values($model->getFirstErrors())[0], 'error');
     } else {
         //            return $this->render('create', [
         //                'model' => $model,
         //            ]);
     }
 }