In Magento 2 if we need hide/show the field in the same group we will fallow as below.
<section id="custom_general" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<group id="general" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General Options</label>
<field id="active" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>Enable/Disable</comment>
</field>
<field id="depends_on_file" translate="File Name" sortOrder="5" type="text" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enter the File Name: </label>
<depends>
<field id="active">1</field>
</depends>
</field>
</group>
</section>
If we use <depends>
it will act like show/hide based on active field.
In my case fields are in the different tab sections and I used the same <depends>
, but not working for me. For this I used below method.
<section id="custom_customer" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<group id="custom_customer_general" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General</label>
<field id="file_name" translate="File Name" sortOrder="5" type="text" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enter the File Name: </label>
<depends>
<field id="custom_general/general/active">1</field>
</depends>
</field>
</group>
</section>
I used the <field id="custom_general/general/active">1</field>
validation to show/hide, but it's not working.
Can you please suggest me if I went wrong?