Search code examples
phpsymfony1symfony-1.4filtering

Symfony 1.4 - How to use backend-filters in table_method?


I'd like to use a custom filter in my table_method to extend a query. Unfortunately I do not know how to access the field's value from within the method. I'm using SF 1.4 /w Doctrine 1.2


Solution

  • I think that you must to change the doBuildQuery filterForm method.

    In any filterForm class you can do:

    public doBuildQuery(array $values) {
        $q = parent::doBuildQuery($values);
    
        if($values['....']) ... {
           $q->addWhere($q->getRootAlias().".column = ?",$values['...']);
        }
    
        return $q; 
    }
    

    This method it's the one automatically called from backend generated modules. If you want to add another widget, do it in configure() method, then process the value in the doBuildQuery().