Created
April 9, 2016 07:41
-
-
Save AjayKumar01/811746beabe270f5c09ab5ed672bcb64 to your computer and use it in GitHub Desktop.
Making field required dynamically based on condition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
/* Making field required dynamically based on condition | |
* Ajay Kumar | |
* Path : custom/modules/Opportunities/clients/base/views/record/record.js | |
*/ | |
extendsFrom: 'RecordView', | |
initialize: function(options) { | |
this._super('initialize', [options]); | |
this.on('render', this.testFunc, this); | |
this.model.on('change:probability', this.testFunc, this); | |
}, | |
testFunc: function() { | |
var probabilityValue = this.model.get('probability'); | |
_.each(this.fields, function(field) { | |
if (_.isEqual(field.def.name, 'opportunity_type') && _.isEqual(probabilityValue, 10)) { | |
field.def.required = true; | |
} | |
}, this); | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment