Ver código fonte

edit comment

amic 1 ano atrás
pai
commit
da655c46f3

+ 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() ?>