Skip to content

Commit

Permalink
MAGETWO-69379: use payment method name to make checkbox of agreements…
Browse files Browse the repository at this point in the history
… more unique #6207 #9717
  • Loading branch information
ishakhsuvarov authored May 26, 2017
2 parents 1432268 + a8e663a commit 14b9b98
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 14b9b98

Please sign in to comment.