[Vtigercrm-developers] VT6 vtlib Filter API

Alan Lord alanslists at gmail.com
Wed Mar 19 08:37:19 GMT 2014


Has the Filter API changed at all in VT6?

I've used this format for all my 5.4.0 custom modules and it works fine, 
but in VT6 it is creating the filter record in vtiger_cvcolumnlist but 
not adding the columns to vtiger_cvcolumnlist...

> // Populate this array with the fieldnames you want, in order!
> $fields = Array('initiativeno', 'lsinitiative_status', 'startdate');
> $filter = Vtiger_Filter::getInstance('All', $module);
> if ($filter != false) {
> 	$filter->delete();
> }
> $filter = new Vtiger_Filter();
> $filter->name = 'All';
> $filter->isdefault = true;
> $module->addFilter($filter);
> // Iteratively add fields to the filter just created
> for ($i = 0; $i <= count($fields) - 1; $i++) {
> 	$field = Vtiger_Field::getInstance($fields[$i], $module);
> 	$filter->addField($field, $i);
> }

The reason I do it this way, by the way, is to reduce the amount of 
typing when creating a module... All fields are just $field when being 
created and then unset again prior to the next one. So to create the 
filter I just grab a new handle to the fields I need and add them in order.

Cheers

Al



More information about the vtigercrm-developers mailing list