- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019
01:46 AM
01-23-2019
01:46 AM
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(); } }); });
Prema M
Solved! Go to Solution.
Labels:
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2019
09:04 PM
01-24-2019
09:04 PM
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; }
Prema M
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2019
09:04 PM
01-24-2019
09:04 PM
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; }
Prema M
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2021
05:56 AM
11-18-2021
05:56 AM
Re: How to hide particular admin form field(UI Component) based on the value of select field?
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