Exemplo n.º 1
0
 public function actionCreate()
 {
     $blogPost = new BlogPost();
     $blogPost->is_published = 1;
     $translations = $blogPost->initializeTranslations();
     Model::loadMultiple($translations, $_POST);
     if ($blogPost->load($_POST) && Model::loadMultiple($translations, $_POST) && Model::validateMultiple($translations) && $blogPost->save()) {
         $blogPost->saveTranslations($translations);
         $blogPost->uploadedFeaturedImage = UploadedFile::getInstance($blogPost, 'uploadedFeaturedImage');
         if ($blogPost->saveFeaturedImageToDisk()) {
             Yii::$app->session->setFlash('success', Yii::t('app', 'Blog Post created successfully'));
         } else {
             Yii::$app->session->setFlash('error', Yii::t('app', 'There was some error uploading the blog post Image'));
         }
         return $this->redirect(['index']);
     }
     return $this->render('create', compact('blogPost', 'translations'));
 }
 public function actionCreate()
 {
     $blogPost = new BlogPost();
     $blogPost->save();
     return $this->redirect(['update', 'id' => $blogPost->id]);
 }