I used the following script and it is working fine. But I want to hide/display the fields without changing the select field options(once the form load completed).
define([
'underscore',
'uiRegistry',
'Magento_Ui/js/form/element/select',
'Magento_Ui/js/modal/modal'
], function (_, uiRegistry, select, modal) {
'use strict';
return select.extend({
/**
* On value change handler.
*
* @param {String} value
*/
onUpdate: function (value) {
var sdate = uiRegistry.get('index = schedule_date');
if(value==1){
sdate.show();
} else {
sdate.hide();
}
return this._super();
}
});
});
Solved! Go to Solution.
Finally, I found a solution to this requirement. While the select field gets initialized, based on its value it, we can hide/display the corresponding fields.
initialize: function () {
this._super();
if (this.customEntry) {
registry.get(this.name, this.initInput.bind(this));
}
if (this.filterBy) {
this.initFilter();
}
var sdate = uiRegistry.get('index = schedule_date');
if(this.value()==1){
sdate.show();
} else {
sdate.hide();
}
return this;
}
Finally, I found a solution to this requirement. While the select field gets initialized, based on its value it, we can hide/display the corresponding fields.
initialize: function () {
this._super();
if (this.customEntry) {
registry.get(this.name, this.initInput.bind(this));
}
if (this.filterBy) {
this.initFilter();
}
var sdate = uiRegistry.get('index = schedule_date');
if(this.value()==1){
sdate.show();
} else {
sdate.hide();
}
return this;
}
Hi,
Can you please keep the whole code of that file.I tried the same way but in mycase the field is not hiding
Thanks in advance