Filterchain Admin Generator, filters and i18n

Source: Internet
Author: User
Tags i18n
Three easy steps
1) Configure function
Add an input for each field want to include in your filter

Copy the Code code 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 the Code code 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'll search in all of them
->andwhere (' CONCAT (T.name, t.shortname) like? ', '% '. $values [' text ']. '%');
}
}


3) Add Your searching fields

Copy the Code code as follows:


Public Function GetFields ()
{
return Parent::getfields () + array (' name ' = = ' Text ');
}


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

The above describes the Filterchain Admin generator, filters and i18n, including the filterchain aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.