Skip to content
Snippets Groups Projects
Commit 0604db3e authored by lobo's avatar lobo
Browse files

Merge pull request #304 from pradpnayak/CRM-12233

-- added form rule for CRM-12233
parents bec527e4 41f27e49
No related branches found
No related tags found
No related merge requests found
......@@ -801,6 +801,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
&& $self->_values['amount_block_is_active']) {
$membershipFieldId = $contributionFieldId = $errorKey = $otherFieldId = NULL;
foreach ($self->_values['fee'] as $fieldKey => $fieldValue) {
// if 'No thank you' membership is selected then set $membershipFieldId
if ($fieldValue['name'] == 'membership_amount' && CRM_Utils_Array::value('price_' . $fieldKey, $fields) == 0) {
$membershipFieldId = $fieldKey;
}
......@@ -817,10 +818,10 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
}
}
}
if ($membershipFieldId && (!CRM_Utils_Array::value('price_' . $contributionFieldId, $fields)
&& !CRM_Utils_Array::value('price_' . $otherFieldId, $fields))) {
$errors["price_{$errorKey}"] = ts('Additional Amount is required.');
// $membershipFieldId is set and additional amount is 'No thank you' or NULL then throw error
if ($membershipFieldId && !(CRM_Utils_Array::value('price_' . $contributionFieldId, $fields, -1) > 0)
&& !CRM_Utils_Array::value('price_' . $otherFieldId, $fields)) {
$errors["price_{$errorKey}"] = ts('Additional Contribution is required.');
}
}
if (empty($check)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment