{"id":11740,"date":"2020-07-07T09:11:44","date_gmt":"2020-07-07T03:41:44","guid":{"rendered":"https:\/\/www.hiddentechies.com\/blog\/?p=11740"},"modified":"2020-10-09T18:59:06","modified_gmt":"2020-10-09T13:29:06","slug":"magento-2-add-dependant-field-admin-system-configuration","status":"publish","type":"post","link":"https:\/\/www.hiddentechies.com\/blog\/magento\/magento-2-add-dependant-field-admin-system-configuration\/","title":{"rendered":"Magento 2 &#8211; How to Add Dependant Field in Admin System Configuration"},"content":{"rendered":"<p>In this post I am going to explain how to add dependant field in admin system configuration in magento 2.<\/p>\n<p>In order to create a field dependant on single value, use the below code:<\/p>\n<pre class=\"lang:default decode:true \">&lt;depends&gt;\r\n\t&lt;field id=\"parent_field_id\"&gt;1&lt;\/field&gt;\r\n&lt;\/depends&gt;<\/pre>\n<p>And to create a field dependant on two or more values, use the below code:<\/p>\n<pre class=\"lang:default decode:true \">&lt;depends&gt;\r\n\t&lt;field id=\"parent_field_id\"&gt;1,2,3&lt;\/field&gt;\r\n&lt;\/depends&gt;<\/pre>\n<p>Here is the example in which, if parent field&#8217;s (Enabled) value &#8220;1&#8221; then &#8220;Title&#8221; field will appear.<\/p>\n<pre class=\"lang:default decode:true \">&lt;field id=\"enabled\" translate=\"label\" type=\"select\" sortOrder=\"1\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\"&gt;\r\n\t&lt;label&gt;Enabled&lt;\/label&gt;\r\n\t&lt;source_model&gt;Magento\\Config\\Model\\Config\\Source\\Yesno&lt;\/source_model&gt;\r\n&lt;\/field&gt;\r\n&lt;field id=\"title\" translate=\"label\" type=\"text\" sortOrder=\"2\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\"&gt;\r\n\t&lt;label&gt;Title&lt;\/label&gt;\r\n\t&lt;depends&gt;\r\n\t\t&lt;field id=\"enabled\"&gt;1&lt;\/field&gt;\r\n\t&lt;\/depends&gt;\r\n&lt;\/field&gt;<\/pre>\n<p>Thats it. Enjoy Magento 2!!<\/p>\n<div class=\"angwp_12010 _ning_cont _ning_hidden _ning_outer _align_center responsive\" data-size=\"custom\" data-bid=\"12010\" data-aid=\"0\" style=\"max-width:800px; width:100%;height:inherit;\"><div class=\"_ning_label _left\" style=\"\"><\/div><div class=\"_ning_inner\" style=\"\"><a href=\"https:\/\/www.hiddentechies.com\/blog?_dnlink=12010&t=1775808895\" class=\"strack_cli _ning_link\" target=\"_blank\">&nbsp;<\/a><div class=\"_ning_elmt\"><img decoding=\"async\" src=\"https:\/\/www.hiddentechies.com\/blog\/wp-content\/uploads\/angwp\/items\/12010\/Banner-2.png\" \/><\/div><\/div><\/div><div class=\"clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>In this post I am going to explain how to add dependant field in admin system configuration in magento 2. In order to create a field dependant on single value, use the below code: &lt;depends&gt; &lt;field id=&#8221;parent_field_id&#8221;&gt;1&lt;\/field&gt; &lt;\/depends&gt; And to create a field dependant on two or more values, use the below code: &lt;depends&gt; &lt;field&#8230; <\/p>\n<div class=\"actions\"><a href=\"https:\/\/www.hiddentechies.com\/blog\/magento\/magento-2-add-dependant-field-admin-system-configuration\/\">Continue Reading<\/a><\/div>\n","protected":false},"author":1,"featured_media":11823,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[181,59,2138],"tags":[10,27],"_links":{"self":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11740"}],"collection":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/comments?post=11740"}],"version-history":[{"count":1,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11740\/revisions"}],"predecessor-version":[{"id":11741,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11740\/revisions\/11741"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media\/11823"}],"wp:attachment":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media?parent=11740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/categories?post=11740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/tags?post=11740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}