コード例 #1
0
 /**
  * Creates a new Tag model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param string|null $backUrl
  * @param bool|null $modal
  * @return mixed
  * @throws NotFoundHttpException
  */
 public function actionCreate($backUrl = null, $modal = null)
 {
     $model = new Tag();
     $model->loadDefaultValues();
     $model->status = Tag::STATUS_PUBLISHED;
     if ($modal) {
         Yii::$app->applyModalLayout();
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if ($modal) {
             ModalIFrame::postData(['id' => $model->id, 'title' => $model->title, 'description' => Yii::t('gromver.platform', 'Tag: {title}', ['title' => $model->title]), 'link' => Yii::$app->urlManager->createUrl($model->getFrontendViewLink()), 'value' => $model->id . ':' . $model->alias]);
         }
         return $this->redirect($backUrl ? $backUrl : ['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }