Admin generator, filters and I18n

前端之家收集整理的这篇文章主要介绍了Admin generator, filters and I18n前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Three easy steps

1) configure function


Add an input for each field you want to include in your filter
<div class="codetitle"><a style="CURSOR: pointer" data="5129" class="copybut" id="copybut5129" onclick="doCopy('code5129')"> 代码如下:
<div class="codebody" id="code5129">
$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.
<div class="codetitle"><a style="CURSOR: pointer" data="96843" class="copybut" id="copybut96843" onclick="doCopy('code96843')"> 代码如下:
<div class="codebody" id="code96843">
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


<div class="codetitle"><a style="CURSOR: pointer" data="74817" class="copybut" id="copybut74817" onclick="doCopy('code74817')"> 代码如下:
<div class="codebody" id="code74817">
public function getFields()
{
return parent::getFields() + array('name' => 'Text');
}

From: http://oldforum.symfony-project.org/index.php/t/24350/

原文链接:https://www.f2er.com/php/27590.html
filtersfiltersgeneratorgenerator

猜你在找的PHP相关文章