Skip to content

Commit 42a7983

Browse files
committed
Giving the possibility to have a config dependency based on empty field value
1 parent 2bd4cb5 commit 42a7983

File tree

2 files changed

+14
-1
lines changed
  • app/code/Magento/Config
    • Model/Config/Structure/Element/Dependency
    • Test/Unit/Model/Config/Structure/Element/Dependency

2 files changed

+14
-1
lines changed

app/code/Magento/Config/Model/Config/Structure/Element/Dependency/Field.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(array $fieldData = [], $fieldPrefix = "")
4141
if (isset($fieldData['separator'])) {
4242
$this->_values = explode($fieldData['separator'], $fieldData['value']);
4343
} else {
44-
$this->_values = [$fieldData['value']];
44+
$this->_values = [isset($fieldData['value']) ? $fieldData['value'] : ''];
4545
}
4646
$fieldId = $fieldPrefix . (isset(
4747
$fieldData['dependPath']

app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/FieldTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class FieldTest extends \PHPUnit\Framework\TestCase
1212
*/
1313
const SIMPLE_VALUE = 'someValue';
1414

15+
const EMPTY_VALUE = '';
16+
1517
const COMPLEX_VALUE1 = 'value_1';
1618

1719
const COMPLEX_VALUE2 = 'value_2';
@@ -150,8 +152,19 @@ public function getValuesDataProvider()
150152
return [
151153
[$this->_getSimpleData(), true, [self::SIMPLE_VALUE]],
152154
[$this->_getSimpleData(), false, [self::SIMPLE_VALUE]],
155+
[$this->_getSimpleEmptyData(), false, [static::EMPTY_VALUE]],
153156
[$this->_getComplexData(), true, $complexDataValues],
154157
[$this->_getComplexData(), false, $complexDataValues]
155158
];
156159
}
160+
161+
/**
162+
* Providing a field data with no field value
163+
*
164+
* @return array
165+
*/
166+
protected function _getSimpleEmptyData(): array
167+
{
168+
return ['dependPath' => ['section_2', 'group_3', 'field_4']];
169+
}
157170
}

0 commit comments

Comments
 (0)