Skip to content

Commit 36b012b

Browse files
committed
skip the validation of parentId on deletion
1 parent 2083417 commit 36b012b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

controllers/DefaultController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public function actionCreate($entity)
131131
public function actionDelete($id)
132132
{
133133
$commentModel = $this->findModel($id);
134+
$commentModel->setScenario(CommentModel::SCENARIO_MODERATION);
134135
$event = Yii::createObject(['class' => CommentEvent::class, 'commentModel' => $commentModel]);
135136
$this->trigger(self::EVENT_BEFORE_DELETE, $event);
136137

models/CommentModel.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class CommentModel extends ActiveRecord
4242
{
4343
use ModuleTrait;
4444

45+
const SCENARIO_MODERATION = 'moderation';
46+
4547
/**
4648
* @var null|array|ActiveRecord[] comment children
4749
*/
@@ -67,7 +69,7 @@ public function rules()
6769
['status', 'default', 'value' => Status::APPROVED],
6870
['status', 'in', 'range' => Status::getConstantsByName()],
6971
['level', 'default', 'value' => 1],
70-
['parentId', 'validateParentID'],
72+
['parentId', 'validateParentID', 'except'=>static::SCENARIO_MODERATION],
7173
[['entityId', 'parentId', 'status', 'level'], 'integer'],
7274
];
7375
}

0 commit comments

Comments
 (0)