Skip to content

Commit

Permalink
Backport of MAGETWO-69379 for Magento 2.1: use payment method name to…
Browse files Browse the repository at this point in the history
… make checkbox of agreements more unique magento#6207 magento#9717

(cherry picked from commit 14b9b98)
  • Loading branch information
ishakhsuvarov authored and hostep committed Feb 7, 2018
1 parent 918dd05 commit 6ec9e22
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ define(
agreementsModal.showModal();
},

/**
* build a unique id for the term checkbox
*
* @param {Object} context - the ko context
* @param {Number} agreementId
*/
getCheckboxId: function (context, agreementId) {
var paymentMethodName = '',
paymentMethodRenderer = context.$parents[1];

// corresponding payment method fetched from parent context
if (paymentMethodRenderer) {
// item looks like this: {title: "Check / Money order", method: "checkmo"}
paymentMethodName = paymentMethodRenderer.item ?
paymentMethodRenderer.item.method : '';
}

return 'agreement_' + paymentMethodName + '_' + agreementId;
},

/**
* Init modal window for rendered element
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<div class="checkout-agreement required">
<input type="checkbox" class="required-entry"
data-bind="attr: {
'id': 'agreement_' + agreementId,
'id': $parent.getCheckboxId($parentContext, agreementId),
'name': 'agreement[' + agreementId + ']',
'value': agreementId
}"/>
<label data-bind="attr: {'for': 'agreement_' + agreementId}">
<label data-bind="attr: {'for': $parent.getCheckboxId($parentContext, agreementId)}">
<button type="button"
class="action action-show"
data-bind="click: function(data, event) { return $parent.showContent(data, event) }"
Expand Down

0 comments on commit 6ec9e22

Please sign in to comment.