[Vtigercrm-developers] extend Validation engine

Alan Lord alanslists at gmail.com
Fri Feb 20 17:01:20 GMT 2015


Following on from the earlier discussion on the new vtiger validation 
engine, I see how I can add a new custom validation to a specific field; 
e.g.

> class Leads_Field_Model extends Vtiger_Field_Model {
>
> 	function getValidator() {
> 		$validator = parent::getValidator();
> 		$fieldName = $this->getName();
> 		switch($fieldName) {
> 			case 'phone' : $funcName = array('name'=>'GlobalPhoneCheck');
> 						    array_push($validator, $funcName);
> 							break;			
> 		}
> 		return $validator;
> 	}
> }

In the above case I'm adding my validation function "GlobalPhoneCheck" 
to the field called "phone" in the Lead module.

Suppose I want to apply this validation check to all UI Type 11 (phone 
number) fields for all/any modules... How do I do that?

Secondly, suppose I want to apply a single validation check to *any* 
editable field on a module record only if the record is *not* a new one?

Cheers

Al





More information about the vtigercrm-developers mailing list