时间:2021-07-01 10:21:17 帮助过:15人阅读
$this->widgetSchema['name'] = new sfWidgetFormFilterInput(array('with_empty' => false));
$this->validatorSchema['name'] = new sfValidatorPass(array('required' => false));
2) add a query modification when filtering for that field
I've done it for Doctrine. Pay atention to the method name addFIELDColumnQuery.
代码如下:
public function addNameColumnQuery(Doctrine_Query $query, $field, $values)
{
if (is_array($values) && isset($values['text']) && '' != $values['text'])
{
$query->leftJoin('r.Translation t')
// ->andWhere('t.lang = ?', $especify_one_language) // or it will search in all of them
->andWhere('CONCAT(t.name, t.shortname) like ?', '%' . $values['text'] . '%');
}
}
3) Add your searching fields
代码如下:
public function getFields()
{
return parent::getFields() + array('name' => 'Text');
}
From: http://oldforum.symfony-project.org/index.php/t/24350/