Home >Backend Development >PHP Tutorial >filterchain Admin generator, filters and I18n

filterchain Admin generator, filters and I18n

WBOY
WBOYOriginal
2016-07-29 08:46:551088browse

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/

以上就介绍了filterchain Admin generator, filters and I18n,包括了filterchain方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn