Closed
Description
In system.xml file a field can depend on another field value; it will be shown or not depending from previous field choice.
It works fine if the field depends on a "select" field but if you try to use a "radios" field dependency the mechanism doesn't work and the field will always be shown.
Preconditions
- Magento 2.1.5
Steps to reproduce
app/code/vendorName/moduleName/etc/adminhtml/system.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="wapone" translate="label" sortOrder="1000">
<label>WaPoNe</label>
</tab>
<section id="stickers" translate="label" type="text"
sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Stickers</label>
<tab>wapone</tab>
<resource>WaPoNe_Stickers::config_stickers</resource>
<group id="stickers_page" translate="label" type="text"
sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Stickers page settings</label>
<field id="discount_calculation" translate="label" type="radios"
sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Discount Calculation</label>
<source_model>WaPoNe\Stickers\Model\Config\Backend\DiscountCalculationType</source_model>
</field>
<field id="discount_category" translate="label" type="text"
sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Discount Product Category</label>
<depends>
<field id="stickers/stickers_page/discount_calculation">automatic</field>
</depends>
</field>
</group>
</section>
</system>
</config>
app/code/vendorName/moduleName/Model/Config/Backend/DiscountCalculationType.php:
<?php
namespace WaPoNe\Stickers\Model\Config\Backend;
use Magento\Framework\Option\ArrayInterface;
class DiscountCalculationType implements ArrayInterface
{
public function toOptionArray()
{
$calculationType = array();
$calculationType[] = [
'value' => 'manual',
'label' => __('Manual')
];
$calculationType[] = [
'value' => 'automatic',
'label' => __('Automatic')
];
return $calculationType;
}
}
Expected result
- discount_calculation value = 'automatic' => discount_category is shown
- discount_calculation value = 'manual' => discount_category is not shown
Actual result
- discount_category is always shown so is not working
If I declare discount_calculation field as "select" type, all works fine
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.2 release lineThe issue has been fixed in 2.3 release lineGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.3 release