You can use a dynamic handler to hide or show a field (along with a bunch of other stuff).
If you want to specifically hide/show a field based on whether someone is currently editing a record or not, you can create a dynamic handler function like the following. (you'll need to assign the dynamicHandler property to this script in the clientDefs json file too, or amend your existing dynamicHandler code)
If you want to specifically hide/show a field based on whether someone is currently editing a record or not, you can create a dynamic handler function like the following. (you'll need to assign the dynamicHandler property to this script in the clientDefs json file too, or amend your existing dynamicHandler code)
HTML Code:
define('custom:views/my-entity-handler', ['dynamic-handler'], function (Dep) { return Dep.extend({ init: function () { // Bind the mode change event and then call function as we want to set it up initially too, not just wait for the event. this.recordView.on('after:mode-change', this.viewModeChange.bind(this)); this.viewModeChange(this); }, viewModeChange: function() { // A bit of console logging console.log(`RecordView mode is ${this.recordView.mode}`); if (this.recordView.mode==='edit') { this.recordView.showField('fieldNameHere'); } else { this.recordView.hideField('fieldNameHere'); } } }); });
Comment