From da5692cda81eff0d7dce889fac1c68ba4acd5ed7 Mon Sep 17 00:00:00 2001 From: serhii-balko Date: Fri, 16 Feb 2018 11:22:01 +0200 Subject: [PATCH] Fix depends field not working for radio elements #11539: case when depends field is not exist --- .../Product/Attribute/Edit/Tab/Front.php | 20 +++---------------- lib/web/mage/adminhtml/form.js | 12 ++++++----- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php index cc50dbde69ee3..a0ca53dce4f50 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php @@ -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' diff --git a/lib/web/mage/adminhtml/form.js b/lib/web/mage/adminhtml/form.js index 2bd3ef86e8f90..c87c0fd05b0e2 100644 --- a/lib/web/mage/adminhtml/form.js +++ b/lib/web/mage/adminhtml/form.js @@ -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; + } } } }