From f8e18be206fd9cbaca10f30a31da37bba1016701 Mon Sep 17 00:00:00 2001
From: Andrii Kasian <akasian@ebay.com>
Date: Fri, 20 Mar 2015 22:21:13 +0200
Subject: [PATCH] MAGETWO-35382: Impossible to add bundle product with required
 option to shopping cart without selecting all available options

---
 .../catalog/product/view/type/bundle/option/checkbox.phtml    | 2 +-
 lib/web/mage/validation.js                                    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/checkbox.phtml b/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/checkbox.phtml
index 00938f3c70c..505a554fe65 100644
--- a/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/checkbox.phtml
+++ b/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/checkbox.phtml
@@ -29,7 +29,7 @@
                         <input class="bundle-option-<?php echo $_option->getId() ?> checkbox product bundle option change-container-classname"
                                id="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>"
                                type="checkbox"
-                               <?php if ($_option->getRequired()) echo 'data-validate="{\'validate-one-required-by-name\':true}"'?>
+                               <?php if ($_option->getRequired()) echo 'data-validate="{\'validate-one-required-by-name\':\'input[name^=&quot;bundle_option[' . $_option->getId() . ']&quot;]:checked\'}"'?>
                                name="bundle_option[<?php echo $_option->getId() ?>][<?php echo $_selection->getId() ?>]"
                                <?php if ($block->isSelected($_selection)) echo ' checked="checked"' ?>
                                <?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>
diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js
index 7632ce9b849..fbcf394becd 100644
--- a/lib/web/mage/validation.js
+++ b/lib/web/mage/validation.js
@@ -916,10 +916,10 @@
             'This is a required field.'
         ],
         "validate-one-required-by-name": [
-            function(v, elm) {
+            function(v, elm, selector) {
                 var name        = elm.name.replace(/([\\"])/g, '\\$1'),
                     container   = this.currentForm,
-                    selector    = 'input[name="' + name + '"]:checked';
+                    selector    = selector === true ? 'input[name="' + name + '"]:checked' : selector;
                 
                 return !!container.querySelectorAll(selector).length;
             },
-- 
GitLab