Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Yii Framework 2 gii extension Change Log
2.0.5 under development
-----------------------

- Enh: #42: Entire preview code now can be copied by pressing CTRL+C (thiagotalma, samdark)
- Enh #42: Entire preview code now can be copied by pressing CTRL+C (thiagotalma, samdark)
- Enh #2022: Added support for GridView filtering on values starting with basic operators to CRUD Generator (lennartvdd)
- Chg #38: Added compatibility with latest Typeahead version (razvanphp)


2.0.4 May 10, 2015
------------------

Expand Down
14 changes: 8 additions & 6 deletions generators/crud/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,16 @@ public function generateSearchConditions()
}
}

$likeConditions = [];
$compareConditions = [];
$hashConditions = [];
foreach ($columns as $column => $type) {
switch ($type) {
case Schema::TYPE_BOOLEAN:
$hashConditions[] = "'{$column}' => \$this->{$column},";
break;
case Schema::TYPE_SMALLINT:
case Schema::TYPE_INTEGER:
case Schema::TYPE_BIGINT:
case Schema::TYPE_BOOLEAN:
case Schema::TYPE_FLOAT:
case Schema::TYPE_DOUBLE:
case Schema::TYPE_DECIMAL:
Expand All @@ -413,10 +415,10 @@ public function generateSearchConditions()
case Schema::TYPE_TIME:
case Schema::TYPE_DATETIME:
case Schema::TYPE_TIMESTAMP:
$hashConditions[] = "'{$column}' => \$this->{$column},";
$compareConditions[] = "->andFilterCompare('{$column}', \$this->{$column})";
break;
default:
$likeConditions[] = "->andFilterWhere(['like', '{$column}', \$this->{$column}])";
$compareConditions[] = "->andFilterCompare('{$column}', \$this->{$column}, 'like')";
break;
}
}
Expand All @@ -427,8 +429,8 @@ public function generateSearchConditions()
. str_repeat(' ', 12) . implode("\n" . str_repeat(' ', 12), $hashConditions)
. "\n" . str_repeat(' ', 8) . "]);\n";
}
if (!empty($likeConditions)) {
$conditions[] = "\$query" . implode("\n" . str_repeat(' ', 12), $likeConditions) . ";\n";
if (!empty($compareConditions)) {
$conditions[] = "\$query" . implode("\n" . str_repeat(' ', 12), $compareConditions) . ";\n";
}

return $conditions;
Expand Down