/** * Creates a new Blog model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Blog(); $items = $model->getBlogTags()->all(); $tags = []; foreach ($items as $item) { $tags[] = $item->name; } $model->tagNames = BlogTags::array2string($tags); $images = ''; //isset($model->getImages()) ? $model->getImages() : FALSE; if ($model->load(Yii::$app->request->post())) { // $model->image = UploadedFile::getInstance($model, 'image'); // if($model->image) // { // $path = Yii::getAlias('@webroot/upload/images/blog/').$model->image->baseName.'.'.$model->image->extension; // $model->image->saveAs($path); // $model->attachImage($path); // } // dump(Yii::$app->request->post()); $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model, 'images' => $images]); } }