];
}
+ if (!empty($field['options'])) {
+ foreach ($field['options'] as $option) {
+ if (!empty($option['membership_type_id.auto_renew'])) {
+ $extra += [
+ 'onclick' => "return showHideAutoRenew(CRM.$(this).data('membershipTypeId'));",
+ ];
+ $this->assign('membershipFieldID', $fieldID);
+ }
+ }
+ }
+
CRM_Price_BAO_PriceField::addQuickFormElement($form,
'price_' . $fieldID,
$field['id'],
$this->addOptionalQuickFormElement('auto_renew');
$this->addExpectedSmartyVariable('renewal_mode');
if ($this->_membershipBlock) {
-
- $membershipTypeIds = $membershipTypes = $radio = $radioOptAttrs = [];
+ $membershipTypeIds = $membershipTypes = $radio = [];
// This is always true if this line is reachable - remove along with the upcoming if.
$membershipPriceset = TRUE;
if ($memType['is_active']) {
$autoRenewMembershipTypeOptions["autoRenewMembershipType_{$value}"] = $this->getConfiguredAutoRenewOptionForMembershipType($value);
if ($allowAutoRenewOpt) {
- $javascriptMethod = ['onclick' => "return showHideAutoRenew( this.value );"];
$allowAutoRenewMembership = TRUE;
}
else {
//add membership type.
$radio[$memType['id']] = NULL;
- $radioOptAttrs[$memType['id']] = $javascriptMethod;
if ($cid) {
//show current membership, skip pending and cancelled membership records,
$membership = $memberships[$memType['id']] ?? NULL;
if ($membership) {
if ($membership["membership_type_id.duration_unit:name"] === 'lifetime') {
unset($radio[$memType['id']]);
- unset($radioOptAttrs[$memType['id']]);
$this->assign('hasExistingLifetimeMembership', TRUE);
unset($memberships[$memType['id']]);
continue;
'data-amount' => $opt[$valueFieldName],
'data-currency' => $currencyName,
'data-price-field-values' => json_encode($customOption),
+ 'data-membership-type-id' => $opt['membership_type_id'] ?? NULL,
'visibility' => $visibility_id,
] + $incomingExtra;
- // @todo - move this back to the only calling function on Contribution_Form_Main.php
- if ($field->name == 'membership_amount') {
- $extra += [
- 'onclick' => "return showHideAutoRenew({$opt['membership_type_id']});",
- 'membership-type' => $opt['membership_type_id'],
- ];
- $qf->assign('membershipFieldID', $field->id);
- }
$choice[$opt['id']] = CRM_Utils_String::purifyHTML($priceOptionText['label']);
$choiceAttrs[$opt['id']] = $extra;
}
$choice['0'] = '<span class="crm-price-amount-label">' . $none . '</span>';
- $choiceAttrs['0'] = ['price' => json_encode([$elementName, '0'])];
+ $choiceAttrs['0'] = [
+ 'price' => json_encode([$elementName, '0']),
+ 'data-membership-type-id' => NULL,
+ ] + $incomingExtra;
}
$element = &$qf->addRadio($elementName, $label, $choice, [], NULL, FALSE, $choiceAttrs);