Skip to content

Commit

Permalink
Fix depends field not working for radio elements #11539: case when de…
Browse files Browse the repository at this point in the history
…pends field is not exist
  • Loading branch information
serhii-balko committed Feb 16, 2018
1 parent 3d5cc51 commit da5692c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,33 +184,19 @@ protected function _prepareForm()
'form_after',
$this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Form\Element\Dependence::class
)->addFieldMap(
"is_wysiwyg_enabled",
'wysiwyg_enabled'
)->addFieldMap(
"is_html_allowed_on_front",
'html_allowed_on_front'
)->addFieldMap(
"frontend_input",
'frontend_input_type'
)->addFieldDependence(
'wysiwyg_enabled',
'frontend_input_type',
'textarea'
)->addFieldDependence(
'html_allowed_on_front',
'wysiwyg_enabled',
'0'
)
->addFieldMap(
)->addFieldMap(
"is_searchable",
'searchable'
)
->addFieldMap(
)->addFieldMap(
"is_visible_in_advanced_search",
'advanced_search'
)
->addFieldDependence(
)->addFieldDependence(
'advanced_search',
'searchable',
'1'
Expand Down
12 changes: 7 additions & 5 deletions lib/web/mage/adminhtml/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,14 @@ define([
} else {
values = valuesFrom[idFrom].values;
fromId = $(idFrom + values[0]);
radioFrom = fromId ? $$('[name="' + fromId.name + '"]:checked') : [];
isInArray = radioFrom.length > 0 && values.indexOf(radioFrom[0].value) !== -1;
isNegative = valuesFrom[idFrom].negative;
if (fromId) {
radioFrom = $$('[name="' + fromId.name + '"]:checked');
isInArray = radioFrom.length > 0 && values.indexOf(radioFrom[0].value) !== -1;
isNegative = valuesFrom[idFrom].negative;

if (!radioFrom || isInArray && isNegative || !isInArray && !isNegative) {
shouldShowUp = false;
if (!radioFrom || isInArray && isNegative || !isInArray && !isNegative) {
shouldShowUp = false;
}
}
}
}
Expand Down

0 comments on commit da5692c

Please sign in to comment.