Admin generator, filters and I18n
更新時(shí)間:2011年10月06日 11:17:28 作者:
You need to modify your EntityFormFilter (where Entity is your object class - Article, Book, etc.).
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/
1) configure function
Add an input for each field you want to include in your filter
復(fù)制代碼 代碼如下:
$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.
復(fù)制代碼 代碼如下:
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
復(fù)制代碼 代碼如下:
public function getFields()
{
return parent::getFields() + array('name' => 'Text');
}
From: http://oldforum.symfony-project.org/index.php/t/24350/
您可能感興趣的文章:
- 在Node.js中使用Javascript Generators詳解
- Java的MyBatis框架中MyBatis Generator代碼生成器的用法
- 深入學(xué)習(xí)python的yield和generator
- Java的Struts框架中append標(biāo)簽與generator標(biāo)簽的使用
- 小議JavaScript中Generator和Iterator的使用
- 詳解JavaScript ES6中的Generator
- python生成器generator用法實(shí)例分析
- Python生成器(Generator)詳解
- Ajax loading gif generator
- 淺析JavaScript 箭頭函數(shù) generator Date JSON
相關(guān)文章
php中使用Curl、socket、file_get_contents三種方法POST提交數(shù)據(jù)
php中使用Curl、socket、file_get_contents三種方法POST提交數(shù)據(jù)的實(shí)現(xiàn)代碼,需要的朋友可以參考下。2011-08-08用PHP讀取和編寫XML DOM的實(shí)現(xiàn)代碼
有許多技術(shù)可用于用 PHP 讀取和編寫 XML。本文提供了三種方法讀取 XML:使用 DOM 庫、使用 SAX 解析器和使用正則表達(dá)式。還介紹了使用 DOM 和 PHP 文本模板編寫 XML。2011-02-02PHP圖像處理技術(shù)實(shí)例總結(jié)【繪圖、水印、驗(yàn)證碼、圖像壓縮】
這篇文章主要介紹了PHP圖像處理技術(shù),結(jié)合實(shí)例形式總結(jié)分析了php繪圖、水印、驗(yàn)證碼、圖像壓縮等相關(guān)函數(shù)、功能與圖形繪制實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-12-12php封裝的數(shù)據(jù)庫函數(shù)與用法示例【參考thinkPHP】
這篇文章主要介紹了php封裝的數(shù)據(jù)庫函數(shù)與用法,基于thinkPHP中數(shù)據(jù)庫操作相關(guān)代碼整理簡化而來,包括針對(duì)數(shù)據(jù)庫的設(shè)置、連接、查詢及日志操作等功能,簡單實(shí)用,需要的朋友可以參考下2016-11-11