public static function formRule($params, $files, $self) {
$errors = array();
$batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate');
+ $fields = array(
+ 'total_amount' => 'Amount',
+ 'financial_type' => 'Financial Type',
+ 'payment_instrument' => 'Paid By',
+ );
//CRM-16480 if contact is selected, validate financial type and amount field.
foreach ($params['field'] as $key => $value) {
- if (!empty($params['primary_contact_id'][$key]) && empty($value['total_amount'])) {
- $errors["field[$key][total_amount]"] = ts('Amount is a required field.');
- }
- if (!empty($params['primary_contact_id'][$key]) && empty($value['financial_type'])) {
- $errors["field[$key][financial_type]"] = ts('Financial Type is a required field.');
+ foreach($fields as $field => $label) {
+ if (!empty($params['primary_contact_id'][$key]) && empty($value[$field])) {
+ $errors["field[$key][$field]"] = ts("$label is a required field.");
+ }
}
}