소스 검색

edit comment

amic 1 년 전
부모
커밋
da655c46f3
2개의 변경된 파일10개의 추가작업 그리고 6개의 파일을 삭제
  1. 9 5
      modules/manager/controllers/CommentsController.php
  2. 1 1
      modules/manager/views/comments/_form.php

+ 9 - 5
modules/manager/controllers/CommentsController.php

@@ -17,6 +17,7 @@ class CommentsController extends BaseController
     /**
      * @inheritDoc
      */
+
     public function behaviors()
     {
         return array_merge(
@@ -103,12 +104,15 @@ class CommentsController extends BaseController
     public function actionUpdate($id)
     {
         $model = $this->findModel($id);
+		if (isset($_POST['Comments'])) {
+			$model->message = $_POST['Comments']['message'];
+			$model->visible = $_POST['Comments']['visible'];
+			if ($model->save()) {
+					return $this->redirect(['view', 'id' => $model->id]);
+			}
+		}
 
-        if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
-            return $this->redirect(['view', 'id' => $model->id]);
-        }
-
-        return $this->render('update', [
+		return $this->render('update', [
             'model' => $model,
         ]);
     }

+ 1 - 1
modules/manager/views/comments/_form.php

@@ -10,7 +10,7 @@ use yii\widgets\ActiveForm;
 
 <div class="comments-form">
 
-    <?php $form = ActiveForm::begin(); ?>
+    <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
 
     <?= $form->field($model, 'id')->textInput() ?>