Three easy steps
1) configure function
Add an input for each field you want to include in your filter
<BR>$this->widgetSchema['name'] = new sfWidgetFormFilterInput(array('with_empty' => false)); <BR>$this->validatorSchema['name'] = new sfValidatorPass(array('required' => false)); <BR>
2) add a query modification when fil
本&文来源gaodai^.ma#com搞#代!码网
搞gaodaima代码tering for that field
I’ve done it for Doctrine. Pay atention to the method name addFIELDColumnQuery.
<BR>public function addNameColumnQuery(Doctrine_Query $query, $field, $values) <BR>{ <BR>if (is_array($values) && isset($values['text']) && '' != $values['text']) <BR>{ <BR>$query->leftJoin('r.Translation t') <BR>// ->andWhere('t.lang = ?', $especify_one_language) // or it will search in all of them <BR>->andWhere('CONCAT(t.name, t.shortname) like ?', '%' . $values['text'] . '%'); <BR>} <BR>} <BR>
3) Add your searching fields
<BR>public function getFields() <BR>{ <BR>return parent::getFields() + array('name' => 'Text'); <BR>} <BR>
From: http://oldforum.symfony-project.org/index.php/t/24350/