diff --git a/extensions/gii/CHANGELOG.md b/extensions/gii/CHANGELOG.md
index fda5880..3ac1c67 100644
--- a/extensions/gii/CHANGELOG.md
+++ b/extensions/gii/CHANGELOG.md
@@ -5,6 +5,7 @@ Yii Framework 2 gii extension Change Log
 ----------------------------
 
 - Bug #1405: fixed disambiguation of relation names generated by gii (qiangxue)
+- Bug: fixed controller in crud template to avoid returning query in findModel() (cebe)
 - Enh #1624: generate rules for unique indexes (lucianobaraglia)
 - Enh #1818: Do not display checkbox column if all rows are empty (johonunu)
 
diff --git a/extensions/gii/generators/crud/templates/controller.php b/extensions/gii/generators/crud/templates/controller.php
index bb5d3f4..f599189 100644
--- a/extensions/gii/generators/crud/templates/controller.php
+++ b/extensions/gii/generators/crud/templates/controller.php
@@ -140,15 +140,18 @@ class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->bas
 <?php
 if (count($pks) === 1) {
 	$condition = '$id';
+	// find() would return Query when $id === null
+	$nullCheck = '$id !== null && ';
 } else {
 	$condition = [];
 	foreach ($pks as $pk) {
 		$condition[] = "'$pk' => \$$pk";
 	}
 	$condition = '[' . implode(', ', $condition) . ']';
+	$nullCheck = '';
 }
 ?>
-		if (($model = <?= $modelClass ?>::find(<?= $condition ?>)) !== null) {
+		if (<?= $nullCheck ?>($model = <?= $modelClass ?>::find(<?= $condition ?>)) !== null) {
 			return $model;
 		} else {
 			throw new NotFoundHttpException('The requested page does not exist.');