I have created a custom js
for customer add form. But I am getting the error "can not read property 'get' of undefined" in console.
Please help. Thanks in advance.
Vendor/CustomCustomer/view/base/web/customercustom.js
define([
"jquery",
'jquery/ui',
'underscore',
'uiRegistry',
'Magento_Ui/js/form/element/select',
'mage/url'
], function (_, uiRegistry, Select) {
'use strict';
return function (Select) {
return Select.extend({
initialize: function (value) {
this._super();
var customerCompany = uiRegistry.get('index = customer_company');
var defaultCompany = uiRegistry.get('index = extension_attributes.company_attributes.company_id');
var vessels = uiRegistry.get('index = customer_vessels');
var customerUsername = uiRegistry.get('index = customer_username');
var password = uiRegistry.get('index = password');
var cnfpassword = uiRegistry.get('index = confirm_password');
if (this.value() != 1) {
customerCompany.show();
defaultCompany.hide();
vessels.show();
customerUsername.show();
password.show();
cnfpassword.show();
} else {
customerCompany.hide();
defaultCompany.show();
vessels.hide();
customerUsername.hide();
password.hide();
cnfpassword.hide();
}
return this;
},
onUpdate: function (value) {
var customerCompany = uiRegistry.get('index = customer_company');
var defaultCompany = uiRegistry.get('index = extension_attributes.company_attributes.company_id');
var customerUsername = uiRegistry.get('index = customer_username');
var password = uiRegistry.get('index = password');
var cnfpassword = uiRegistry.get('index = confirm_password');
if (value != 1) {
customerCompany.show();
defaultCompany.hide();
customerUsername.show();
password.show();
cnfpassword.show();
} else {
customerCompany.hide();
defaultCompany.show();
customerUsername.hide();
password.hide();
cnfpassword.hide();
}
return this._super();
},
});
}
});