[Vtigercrm-developers] extend Validation engine

Alan Lord alanslists at gmail.com
Tue Feb 10 13:50:55 GMT 2015


On 10/02/15 13:23, Jonathan Sardo wrote:
> Are you speaking about ajax edition?

I guess so.

This is my kind of thinking right now:

> jQuery(window).load(function() { // Hold off until page fully loaded
>     var module = app.getModuleName();
>     var view = app.getViewName();
>     var moduleClassName = module+"_"+view+"_Js";
>     if(typeof window[moduleClassName] != 'undefined') {
>
>         window[moduleClassName]("LSValidation_Intercept_Js",{
>
>             interceptInstance : false,
>
> 	        getInstance: function(){
> 		        if(LSValidation_Intercept_Js.interceptInstance == false){
> 			        var instance = new LSValidation_Intercept_Js();
> 			        LSValidation_Intercept_Js.interceptInstance = instance;
> 		        }
> 		        return LSValidation_Intercept_Js.interceptInstance;
> 	        },
>
>             init : function() {
>                 this.interceptInstance = LSValidation_Intercept_Js.getInstance();
>                 console.log(this.interceptInstance); // Check we're running
>             }
>         },{
>
>             saveFieldValues : function(fieldDetailList){
>                 var thisInstance = this;
>                 var targetFn = this._super;
>
>                 console.log(fieldDetailList);
>
>                 // If we pass our own validations then
>                 // pass back to parent function
>
>        			return targetFn.call(thisInstance, fieldDetailList);
>             },
>
>             registerEvents : function(){
>                 this._super();
>             }
>
>         });
>     }
> });

This should load my javascript library as an extended class of the 
underlying module (I will include some tests to limit the loading of it 
if it is not Detail or Edit view etc...)

But I can't get the override of the saveFieldValues() call to trigger. 
The above is basically how the Accounts_Detail_Js overrides the standard 
Vtiger_Detail_Js saveFieldValues function.

My idea being to have two override functions in here; one for 
Detail/Summary views and one for Edit View. If this kind of method can 
work then ultimately it should also be possible to deal with the Quick 
Create in a similar way too.

Al




More information about the vtigercrm-developers mailing list