Admin generator, filters and I18n
程序员文章站
2022-04-09 09:22:36
three easy steps 1) configure function add an input for each field you want to include...
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:
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:
上一篇: .Net 使用 Aspose.Words 进行 Word替换操作
下一篇: 十天学会php(3)