Admin generator, filters and I18n

Source: Internet
Author: User
Tags i18n

Three easy steps

1) configure function
Add an input for each field you want to include in your filter
Copy codeThe Code is as follows:
$ 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.
Copy codeThe Code is as follows:
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

Copy codeThe Code is as follows:
Public function getFields ()
{
Return parent: getFields () + array ('name' => 'text ');
}

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.