Skip to content

Instantly share code, notes, and snippets.

@avtaniket
Created June 30, 2015 07:12
Show Gist options
  • Save avtaniket/7eb1745f161ef86efce1 to your computer and use it in GitHub Desktop.
Save avtaniket/7eb1745f161ef86efce1 to your computer and use it in GitHub Desktop.
Conditionaly adding Field Validation to the Edit View in SugarCRM
({
extendsFrom: 'RecordView',
initialize: function (options) {
this._super('initialize', [options]);
//add validation
this.model.addValidationTask('note', _.bind(this.doValidateTicketNote, this));
},
/* add validation for note */
doValidateTicketNote: function(fields, errors, callback) {
if (_.isEmpty(this.model.get('note'))) {
errors['note'] = errors['note'] || {};
errors['note'].required = true;
}
callback(null, fields, errors);
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment