This can be done using virtual columns , just like the message you found. A virtual column is a way to add new filtering criteria using the auto-generated filter provided by symfony. It works as follows:
1 - go to the admin module .yml generator and add the name of the virtual column that will create and add
filter: [virtual_column_name, and, other, filter, columns]
2 - In your lib / filter / {TableName} FormFilter.class.php (I think in your case there should be HeadingFormFilter), you should define this virtual column in the configure () / p> method
public function configure() { //Type of widget (could be sfWidgetFormChoice with bank names) $this->widgetSchema['virtual_column_name'] = new sfWidgetFormInputText(array( 'label' => 'Virtual Column Label' )); //Type of validator for filter $this->validatorSchema['virtual_column_name'] = new sfValidatorPass(array ('required' => false)); }
3 - override getFields () of this class to define it in the filter and set the filter function
public function getFields() { $fields = parent::getFields();
4 - Finally, you must define a filter method. This method should be called after the template to add ... ColumnQuery , in our case there should be addVirtualColumnNameColumnQuery (and not the choice of a happy name: P), therefore
public function addVirtualColumnNameColumnQuery($query, $field, $value) { //add your filter query! //for example in your case $rootAlias = $query->getRootAlias(); $query->innerJoin($rootAlias . '.ImportProfile ip') ->andWhere('ip.BankId = ?', $value); //remember to return the $query! return $query; }
Done! You can find out the filter by bank_id.
source share