[Vtigercrm-developers] extend Validation engine

Uma S uma.s at vtiger.com
Wed Feb 11 06:05:15 GMT 2015


Hi Alan,

I hope you can make use field model level getValidator() api to define
special validator for fields, which can be defined in particular module js
files based on view.

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

> 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
>
>
> _______________________________________________
> 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/20150211/6afbac40/attachment-0001.html>


More information about the vtigercrm-developers mailing list