Code:
define('custom:views/xray-machine/fields/xray-modality-category', ['views/fields/link'], function (Dep) {
return Dep.extend({
setup: function () {
//call parent setup
Dep.prototype.setup.call(this);
this.validations.push('linkDependent');
this.listenTo(this.model,'before:save', () => {
if( this.validate() ) {
Espo.Ui.error('Invalid', true);
throw new Error('Invalid'); //Without this line, the validation proceeds but the record still saves... ? How do stop inlineEditSave from saving the record ?
}
});
},
validateLinkDependent: function () {
console.log('called: validateLinkDependent');
if(true) { // my custom validation logic here
let msg = this.translate('fieldInvalid', 'messages')
.replace('{field}', this.getLabelText());
this.showValidationMessage(msg);
return true;
}
},
});
});

Leave a comment: