I want Hide/show admin form field on toggle value using UiComponent.

when enable the toggle fields should be visible and on disable the toggle fields should not be visible.

[When enable the toggle][1]
[When Disable the toggle][2]

1 Answer 1

You can use below code for Hide/show admin form field and change field name accordingly.


], function (_, uiRegistry, select, modal) {
    'use strict';

    return select.extend({

         * On value change handler.
         * @param {String} value
        onUpdate: function (value) {
            console.log('Selected Value: ' + value);

            var field1 = uiRegistry.get('index = test2');
            if (field1.visibleValue == value) {
            } else {

            var field2 = uiRegistry.get('index = test3');
            if (field2.visibleValue == value) {
            } else {

            return this._super();


  • Do you have any idea how to do same with text input, like if we open form in edit mode then only field should be visible? Commented Jan 13, 2020 at 9:24
  • @RonakChauhan I don't have implement for text input. But you can try with get text input value and check, might that things you can help. Commented Jan 21, 2020 at 9:52
  • I have found the solution for text toggle. it can work without js @Kirti Nariya Commented Jan 21, 2020 at 10:05
  • @RonakChauhan It is a nice. can you please share that solution as you get. so also it is helpful in future. Commented Jan 21, 2020 at 10:08
  • here it is: magento.stackexchange.com/questions/301052/… Commented Jan 21, 2020 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.