/** * Creates a new Tag model. * If creation is successful, the browser will be redirected to the 'view' page. * @param string|null $language * @param string|null $sourceId * @param string|null $backUrl * @param bool|null $modal * @return mixed * @throws NotFoundHttpException */ public function actionCreate($sourceId = null, $language = null, $backUrl = null, $modal = null) { $model = new Tag(); $model->loadDefaultValues(); $model->language = $language ? $language : Yii::$app->language; $model->status = Tag::STATUS_PUBLISHED; if ($sourceId && $language) { $sourceModel = $this->findModel($sourceId); $model->language = $language; $model->translation_id = $sourceModel->translation_id; $model->alias = $sourceModel->alias; $model->status = $sourceModel->status; $model->metakey = $sourceModel->metakey; $model->metadesc = $sourceModel->metadesc; } else { $sourceModel = null; } if ($modal) { Yii::$app->grom->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, 'sourceModel' => $sourceModel]); } }