From 1b497ad73be9f80e5fb122419ffe2c06875dfe56 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 1 Nov 2013 13:23:05 +0400 Subject: [PATCH] Fixes #1107: if basename of Gii CRUD model and search model are equal than alias is automatically used for search model --- framework/yii/gii/generators/crud/templates/controller.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/framework/yii/gii/generators/crud/templates/controller.php b/framework/yii/gii/generators/crud/templates/controller.php index d1921de..a863b30 100644 --- a/framework/yii/gii/generators/crud/templates/controller.php +++ b/framework/yii/gii/generators/crud/templates/controller.php @@ -12,6 +12,9 @@ use yii\helpers\StringHelper; $controllerClass = StringHelper::basename($generator->controllerClass); $modelClass = StringHelper::basename($generator->modelClass); $searchModelClass = StringHelper::basename($generator->searchModelClass); +if ($modelClass === $searchModelClass) { + $searchModelAlias = $searchModelClass.'Search'; +} $pks = $generator->getTableSchema()->primaryKey; $urlParams = $generator->generateUrlParams(); @@ -24,7 +27,7 @@ echo "controllerClass, '\\')) ?>; use modelClass, '\\') ?>; -use searchModelClass, '\\') ?>; +use searchModelClass, '\\') ?> as ; use yii\data\ActiveDataProvider; use baseControllerClass, '\\') ?>; use yii\web\HttpException; @@ -53,7 +56,7 @@ class extends bas */ public function actionIndex() { - $searchModel = new ; + $searchModel = new ; $dataProvider = $searchModel->search($_GET); return $this->render('index', [