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下用GD生成生成缩略图的两个选择和区别

php下用GD生成生成缩略图的两个选择和区别

PHP的GD扩展提供了两个函数来缩放图像:ImageCopyResized(dest, src, dx, dy, sx, sy, dw, dh, sw, sh);ImageCopyRes...

php结合安卓客户端实现查询交互实例

PHP 服务器端: function getids() { $this->output->set_header('Content-Type: application...

PHP PDOStatement对象bindpram()、bindvalue()和bindcolumn之间的区别

PDOStatement::bindParam — 绑定一个参数到指定的变量名。 绑定一个PHP变量到用作预处理的SQL语句中的对应命名占位符或问号占位符。 不同于 PDOStateme...

PHP中获取内网用户MAC地址(WINDOWS/linux)的实现代码

复制代码 代码如下: function ce_getmac() { if(PHP_OS == 'WINNT') { $return_array = array(); $temp_arra...

php 静态化实现代码

模板文件template.htm: 复制代码 代码如下:<html> <head> <title>%title%</title> <...