[Vtigercrm-developers] extend Validation engine

Uma S uma.s at vtiger.com
Sat Feb 21 14:34:54 GMT 2015


Hi Alan,

*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?*

This can be achieved at Field model level, like you already know if for all
module in Vtiger_Field_Model and if for few module then particular module
Field_Model level in getValidator api(), by checking uitype of field
instead of fieldname.

*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?*

If you want apply validation on a record only if it's not new, then we need
to check on mode of record whether it is edit mode and apply validation.

Hope this might add some value for discussion.

On Fri, Feb 20, 2015 at 10:31 PM, Alan Lord <alanslists at gmail.com> wrote:

> 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
>
>
>
> _______________________________________________
> http://www.vtiger.com/
>



-- 
With
Best Regards
Uma.S
Vtiger Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20150221/7a2262af/attachment.html>


More information about the vtigercrm-developers mailing list