Skip to content

Commit

Permalink
Updated FilterComponent for VirtualFields
Browse files Browse the repository at this point in the history
Added support for virtualFields as part of table columns and modified the search to have broader results.
  • Loading branch information
TeckniX committed Feb 27, 2014
1 parent 2e3c2cb commit 3efa33f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Controller/Component/FilterComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class FilterComponent extends Component {
* fields which will replace the regular syntax in where i.e. field = 'value'
*/
var $fieldFormatting = array(
"string"=>array("%1\$s LIKE", "%2\$s%%"),
"text"=>array("%1\$s LIKE", "%2\$s%%"),
"string"=>array("%1\$s LIKE", "%%%2\$s%%"),
"text"=>array("%1\$s LIKE", "%%%2\$s%%"),
"checkbox"=>array("%1\$s =>", "%2\$s%%"),
"date"=>array("DATE_FORMAT(%1\$s, '%%d-%%m-%%Y')", "%2\$s"),
"datetime"=>array("DATE_FORMAT(%1\$s, '%%d-%%m-%%Y')", "%2\$s")
Expand Down Expand Up @@ -55,6 +55,13 @@ function generateCondition($object, $data=false){
}
if(isset($object->{$model})){ //This is object under current object.
$columns = $object->{$model}->getColumnTypes();
// Add virtualFields to the columns
$virtuals = $object->{$model}->getVirtualField();
if(!empty($virtuals)){
foreach($virtuals as $column=>$virtual){
$columns[$column] = gettype($virtual);
}
}
foreach($filter as $field=>$value){
if(is_array($value)){ //Possible that this node is another model
if(in_array($field, array_keys($columns))){ //The field is from the model, but it has special formatting
Expand Down

0 comments on commit 3efa33f

Please sign in to comment.