diff --git a/src/generators/crud/default/controller.php b/src/generators/crud/default/controller.php index b7049e72a..1f440d1f7 100644 --- a/src/generators/crud/default/controller.php +++ b/src/generators/crud/default/controller.php @@ -147,7 +147,12 @@ public function actionDelete() { $this->findModel()->delete(); - return $this->redirect(['index']); + list($actionID) = Yii::$app->createController(parse_url(Yii::$app->request->referrer, PHP_URL_PATH)); + if ($actionID === 'index') { + return $this->redirect(Yii::$app->request->referrer); + } else { + return $this->redirect(['index']); + } } /**