Skip to content

Instantly share code, notes, and snippets.

@AjayKumar01
Created April 9, 2016 07:41
Show Gist options
  • Save AjayKumar01/811746beabe270f5c09ab5ed672bcb64 to your computer and use it in GitHub Desktop.
Save AjayKumar01/811746beabe270f5c09ab5ed672bcb64 to your computer and use it in GitHub Desktop.
Making field required dynamically based on condition
({
/* 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