Hello,
I extended a field view like:
When I go to edit the entity and then click save, it appears to invoke validate but an error is thrown?
[Error] TypeError: undefined is not an object (evaluating 'this[method].call')
validate (base.js:1442)
validateField (base.js:851)
(anonymous function) (base.js:811)
forEach
validate (base.js:810)
save (base.js:1043)
actionSave (detail.js:522)
handleAction (utils.js:75)
click .button-container .action (detail.js:468)
executeBound (underscore.js:986)
(anonymous function) (underscore.js:1018)
(anonymous function) (underscore.js:74)
dispatch (jquery.js:5430)
This is strange to me because the built in validateRequired function of views/fields/link seems to be constructed the same way and it works fine.
I extended a field view like:
Code:
define('custom:views/xray-machine/fields/xray-modality-category', ['views/fields/link'], function (Dep) {
setup: function () {
//call parent setup
Dep.prototype.setup.call(this);
this.validations.push('validateLinkDependent');
},
validateLinkDependent: function () {
//TODO fix this
console.log('called: validateLinkDependent');
let msg = this.translate('fieldInvalid', 'messages')
.replace('{field}', this.getLabelText());
this.showValidationMessage(msg);
return true;
},
})
[Error] TypeError: undefined is not an object (evaluating 'this[method].call')
validate (base.js:1442)
validateField (base.js:851)
(anonymous function) (base.js:811)
forEach
validate (base.js:810)
save (base.js:1043)
actionSave (detail.js:522)
handleAction (utils.js:75)
click .button-container .action (detail.js:468)
executeBound (underscore.js:986)
(anonymous function) (underscore.js:1018)
(anonymous function) (underscore.js:74)
dispatch (jquery.js:5430)
This is strange to me because the built in validateRequired function of views/fields/link seems to be constructed the same way and it works fine.
Code:
validateRequired: function () {
if (this.isRequired()) {
if (this.model.get(this.idName) == null) {
var msg = this.translate('fieldIsRequired', 'messages')
.replace('{field}', this.getLabelText());
this.showValidationMessage(msg);
return true;
}
}
},

Comment