Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Marco Matta
Added: Sep 2, 2021 8:09 AM
Views: 298
Tags: sugarcrm
  1. ({
  2.     extendsFrom: 'CreateView',
  3.     initialize: function (options)
  4.     {
  5.  
  6.         this._super('initialize', [options]);
  7.  
  8.         this.model.addValidationTask('validationFunction', _.bind(this._doValidate, this));
  9.     },
  10.  
  11.     _doValidate: function(fields, errors, callback)
  12.     {
  13.         //validate type requirements
  14.         if (this.model.get('field_1') == 'Value' && _.isEmpty(this.model.get('field_2')))
  15.         {
  16.             errors['field_2'] = errors['field_2'] || {};
  17.             errors['field_2'].required = true;
  18.         }
  19.  
  20.         callback(null, fields, errors);
  21.     }
  22. })