Admin generator, filters and I18n

yipeiwu_com6年前PHP代码库
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/

相关文章

php指定长度分割字符串str_split函数用法示例

本文实例讲述了php指定长度分割字符串str_split函数用法。分享给大家供大家参考,具体如下: 示例1: $str = 'abcdefgh'; $arr = str_split(...

PHP正则表达式 /i, /is, /s, /isU等介绍

PHP正则表达式 /i, /is, /s, /isU等 都是些什么东西呢? i 不区分大小写 s 模式中的圆点元字符(.)匹配所有的字符,包括换行符 x 模式中的空白字符除了被转义的或在...

PHP中4个加速、缓存扩展的区别和选用建议

折腾VPS的朋友,在安装好LNMP等Web运行环境后都会选择一些缓存扩展安装以提高PHP运行速度,常被人介绍的有eAccelerator、memcached、xcache、Alterna...

Php header()函数语法及使用代码

语法:复制代码 代码如下:Void header(string $string[,bool $replace=true [, int $http_response_code)向客户端发送...

PHP处理bmp格式图片的方法分析

本文分析了PHP处理bmp格式图片的方法。分享给大家供大家参考,具体如下: 白天QA提出项目上传图片有问题,具体为:上传成功,预览失败。我去了之后,又上传了几张其他的图片可以上传,然后仔...