While surfing online, you probably have filled hundreds of forms whether it is related to signup, contact or anything. If you have noticed when you select one particular option it shows other relevant options to select from. Such options are known as Field Dependencies controls. It hides unnecessary fields until you don’t make a relational choice. Using such field dependencies in the form helps you to prevent bad user experience and collect all related information in less time.
While creating an extension from scratch many times it happens that you have so many configurations but some of them are dependable at that time, you have to create field dependencies.
For example, here we have used a dropdown field to show or hide dependable textbox. If the user selects “show” it shows the dependable textbox else it will gets hidden.
Once you create a basic form now inside your custom extension folder. After that, you have to add below code in your “form.php” file.
app\code\Vendor\Extension\Block\Adminhtml\Grid\Edit\Tab\Form.php

That’s it. You are free to manipulate this code according to your need to show hide multiple form controls.

Lastly, if you found this blog helpful, don’t forget to share it with your colleagues and Magento Friends and Let us know if you are facing any issue while implementing this code.

Happy Fixing!

Click to rate this post!
[Total: 9 Average: 5]