Handled required custom fields

This commit is contained in:
CiviWare Solutions 2018-12-23 00:16:53 +00:00
parent 6175e0623f
commit 54ab2b53bb

View File

@ -188,7 +188,18 @@ function softcreditcustomfields_civicrm_buildForm($formName, &$form) {
); );
_softcreditcustomfields_addCustomDataToForm($form, $entityId, $blockId); _softcreditcustomfields_addCustomDataToForm($form, $entityId, $blockId);
} }
if ($form->_flagSubmitted) {
$submitValues = $form->_submitValues;
foreach ($form->_required as $key => $fieldName) {
if (strpos($fieldName, 'soft_credit_custom[') !== FALSE) {
$fieldName = str_replace('soft_credit_custom[', '', $fieldName);
$blockId = strstr($fieldName, ']', TRUE);
if (empty($submitValues['soft_credit_amount'][$blockId])) {
unset($form->_required[$key]);
}
}
}
}
} }
} }
/** /**
@ -234,10 +245,6 @@ function _softcreditcustomfields_addCustomDataToForm(&$form, $entityId, $blockId
// And we can't set it to 'soft_credit_' because we want to set it in a slightly different format. // And we can't set it to 'soft_credit_' because we want to set it in a slightly different format.
CRM_Core_BAO_CustomGroup::buildQuickForm($form, $groupTree, FALSE, 'dnc_'); CRM_Core_BAO_CustomGroup::buildQuickForm($form, $groupTree, FALSE, 'dnc_');
// during contact editing : if no softCredit is filled
// required custom data must not produce 'required' form rule error
// more handling done in formRule func
//self::storeRequiredCustomDataInfo($form, $groupTree);
$tplGroupTree = CRM_Core_Smarty::singleton() $tplGroupTree = CRM_Core_Smarty::singleton()
->get_template_vars('soft_credit_custom_groupTree'); ->get_template_vars('soft_credit_custom_groupTree');
$tplGroupTree = empty($tplGroupTree) ? [] : $tplGroupTree; $tplGroupTree = empty($tplGroupTree) ? [] : $tplGroupTree;