In this post we will learn how to create a dependent field in Magento 2 admin system configuration field by XML.
So, now please open etc\adminhtml\system.xml file where this file is located in a custom module and define your configuration dropdown with a custom source model is the our first field.
Above xml code in which, on select field (custom_option_field) option with value “2” from a drop-down list a text field (dependant_field) will appear.
And if you want to create a field dependent on two or more values, use the follow code.
In above code if you select options with values “1” or “2” from (custom_option_field) dropdown list then the text field (dependant_field) will be appeared in the admin configuration.
After then, we need to create that source model for CustomOption:
Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Please SHARE this post.