public function executeFormWidget(dmWebRequest $request) { $form = new ArticleForm(); if ($request->hasParameter($form->getName()) && $form->bindAndValid($request)) { $form->save(); $this->redirectBack(); } $this->forms['Article'] = $form; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = new ArticleForm('view', $id); if (isset($_POST['ArticleForm'])) { $model->attributes = $_POST['ArticleForm']; $model->postItem->attributes = $_POST['PostItem']; $model->article->attributes = $_POST['Article']; $fileUpload = CUploadedFile::getInstance($model->article, 'article_image'); Yii::log(CVarDumper::dumpAsString($fileUpload)); if ($fileUpload !== null) { $model->article->removeImage(); $model->article->article_image = $fileUpload; } if ($model->validate() && $model->save()) { if ($fileUpload !== null) { $model->article->article_image->saveAs(Yii::app()->basePath . '/../files/images/articles/' . $model->article->article_image . "_" . $model->article->getPrimaryKey()); } $this->redirect(array('view', 'id' => $model->article->post_item_id)); } } $this->render('update', array('model' => $model)); }