当前位置: 移动技术网 > IT编程>开发语言>PHP > Admin generator, filters and I18n

Admin generator, filters and I18n

2019年04月19日  | 移动技术网IT编程  | 我要评论
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:

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网