Admin generator, filters and I18n

时间:2021-05-28

Three easy steps

1) configure function
Add an input for each field you want to include in your filter
复制代码 代码如下:
$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/

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章