/**
* Function to set variables up before form is built
*
+ * @param $form
+ *
* @return void
* @access static
*/
* @return void
*/
static function buildQuickForm(&$form) {
- if ($form->_mode == 'live' && $form->_honor_block_is_active) {
+ if ($form->_mode == 'live' && !empty($form->_honor_block_is_active)) {
$ufJoinDAO = new CRM_Core_DAO_UFJoin();
$ufJoinDAO->module = 'soft_credit';
$ufJoinDAO->entity_id = $form->_id;
}
$softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
- $extraOption = array('onclick' => "enableHonorType();");
// radio button for Honor Type
foreach ($jsonData['soft_credit_types'] as $value) {
- $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value, $extraOption);
+ $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
}
- $form->addGroup($honorTypes, 'soft_credit_type_id', NULL);
+ $form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
}
}
return $form;
if ($form->getAction() & CRM_Core_Action::UPDATE) {
$form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
}
- elseif ($form->_pledgeID) {
+ elseif (!empty($form->_pledgeID)) {
//Check and select most recent completed contrubtion and use it to retrieve
//soft-credit information to use as default for current pledge payment, CRM-13981
$pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
* Function used to set defaults for soft credit block
*/
static function setDefaultValues(&$defaults, &$form) {
+ //Used to hide/unhide PCP and/or Soft-credit Panes
+ $noPCP = $noSoftCredit = TRUE;
if (!empty($form->_softCreditInfo['soft_credit'])) {
+ $noSoftCredit = FALSE;
foreach ($form->_softCreditInfo['soft_credit'] as $key => $value) {
$defaults["soft_credit_amount[$key]"] = CRM_Utils_Money::format($value['amount'], NULL, '%a');
$defaults["soft_credit_contact_id[$key]"] = $value['contact_id'];
}
}
if (!empty($form->_softCreditInfo['pcp_id'])) {
+ $noPCP = FALSE;
$pcpInfo = $form->_softCreditInfo;
$pcpId = CRM_Utils_Array::value('pcp_id', $pcpInfo);
$pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'title');
$defaults['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcpInfo);
$defaults['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcpInfo);
}
+
+ $form->assign('noSoftCredit', $noSoftCredit);
+ $form->assign('noPCP', $noPCP);
}
/**
* global form rule
*
- * @param array $fields the input form values
+ * @param array $fields the input form values
+ *
+ * @param $errors
+ * @param $self
*
- * @return true if no errors, else array of errors
+ * @return array of errors
* @access public
* @static
*/