/**
  * Creates a new Template model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Template();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Template model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Template();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('template-create-success');
         return $this->redirect(['/template/update', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionAdd()
 {
     $this->layout = 'default';
     $count = Template::find()->count();
     $count++;
     $model = new Template();
     $model->count_placeholder = 0;
     $model->weight = $count;
     if ($model->save()) {
         $model->name = '#' . $model->id;
         if ($model->update(false)) {
             $this->redirect(Url::toRoute(['templates/edit', 'id' => $model->id]));
         } else {
             Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Не удалось обновить имя макета.'));
             $this->redirect(Url::toRoute(['templates/edit', 'id' => $model->id]));
         }
     } else {
         Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Не удалось сохранить макет.'));
         $this->redirect(Url::toRoute(['templates/index']));
     }
     return;
 }