From ba9f5d6521ccc49415f1f1ecdea019be92f8b86d Mon Sep 17 00:00:00 2001 From: Thiago Talma Date: Thu, 20 Feb 2014 17:20:10 -0300 Subject: [PATCH] Allow add a condition telling the table to avoid ambiguity error. --- extensions/gii/generators/crud/templates/search.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extensions/gii/generators/crud/templates/search.php b/extensions/gii/generators/crud/templates/search.php index bc55c60..40158af 100644 --- a/extensions/gii/generators/crud/templates/search.php +++ b/extensions/gii/generators/crud/templates/search.php @@ -69,7 +69,13 @@ class extends Model protected function addCondition($query, $attribute, $partialMatch = false) { - $value = $this->$attribute; + if (($pos = strrpos($attribute, '.')) !== false) { + $modelAttribute = substr($attribute, $pos + 1); + } else { + $modelAttribute = $attribute; + } + + $value = $this->$modelAttribute; if (trim($value) === '') { return; }