Skip to content

Commit da5692c

Browse files
committed
Fix depends field not working for radio elements #11539: case when depends field is not exist
1 parent 3d5cc51 commit da5692c

File tree

2 files changed

+10
-22
lines changed
  • app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab
  • lib/web/mage/adminhtml

2 files changed

+10
-22
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -184,33 +184,19 @@ protected function _prepareForm()
184184
'form_after',
185185
$this->getLayout()->createBlock(
186186
\Magento\Backend\Block\Widget\Form\Element\Dependence::class
187-
)->addFieldMap(
188-
"is_wysiwyg_enabled",
189-
'wysiwyg_enabled'
190187
)->addFieldMap(
191188
"is_html_allowed_on_front",
192189
'html_allowed_on_front'
193190
)->addFieldMap(
194191
"frontend_input",
195192
'frontend_input_type'
196-
)->addFieldDependence(
197-
'wysiwyg_enabled',
198-
'frontend_input_type',
199-
'textarea'
200-
)->addFieldDependence(
201-
'html_allowed_on_front',
202-
'wysiwyg_enabled',
203-
'0'
204-
)
205-
->addFieldMap(
193+
)->addFieldMap(
206194
"is_searchable",
207195
'searchable'
208-
)
209-
->addFieldMap(
196+
)->addFieldMap(
210197
"is_visible_in_advanced_search",
211198
'advanced_search'
212-
)
213-
->addFieldDependence(
199+
)->addFieldDependence(
214200
'advanced_search',
215201
'searchable',
216202
'1'

lib/web/mage/adminhtml/form.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,14 @@ define([
456456
} else {
457457
values = valuesFrom[idFrom].values;
458458
fromId = $(idFrom + values[0]);
459-
radioFrom = fromId ? $$('[name="' + fromId.name + '"]:checked') : [];
460-
isInArray = radioFrom.length > 0 && values.indexOf(radioFrom[0].value) !== -1;
461-
isNegative = valuesFrom[idFrom].negative;
459+
if (fromId) {
460+
radioFrom = $$('[name="' + fromId.name + '"]:checked');
461+
isInArray = radioFrom.length > 0 && values.indexOf(radioFrom[0].value) !== -1;
462+
isNegative = valuesFrom[idFrom].negative;
462463

463-
if (!radioFrom || isInArray && isNegative || !isInArray && !isNegative) {
464-
shouldShowUp = false;
464+
if (!radioFrom || isInArray && isNegative || !isInArray && !isNegative) {
465+
shouldShowUp = false;
466+
}
465467
}
466468
}
467469
}

0 commit comments

Comments
 (0)