From eac283fcb024209dcc94545e5ea6bf458a78bb00 Mon Sep 17 00:00:00 2001
From: kurund <kurund@civicrm.org>
Date: Sat, 3 Aug 2013 01:13:19 +0530
Subject: [PATCH] CRM-13078, fixed to show correct icon and to hide error
 messages

----------------------------------------
* CRM-13078: Batch Data Entry silently drops 'batch-valid' entries if no contact_id is associated with them
  http://issues.civicrm.org/jira/browse/CRM-13078
---
 templates/CRM/Batch/Form/Entry.tpl | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/templates/CRM/Batch/Form/Entry.tpl b/templates/CRM/Batch/Form/Entry.tpl
index 4f7b0d7ce9..a3f86cedf9 100644
--- a/templates/CRM/Batch/Form/Entry.tpl
+++ b/templates/CRM/Batch/Form/Entry.tpl
@@ -111,7 +111,7 @@ cj(function () {
     cj("#Entry").ajaxSubmit(options);
   });
 
-  cj('#crm-container').on('keyup change', '*', function () {
+  cj('#crm-container').on('keyup change', '*.selector-rows', function () {
     // validate rows
     checkColumns(cj(this));
   });
@@ -214,10 +214,15 @@ function checkColumns(parentRow) {
         inValidRow++;
       }
       else {
-        if (cj(this).val() && !cj('input[name="primary_contact_select_id[' + rowID + ']"]').val()) {
+        var contactIdElement = cj('input[name="primary_contact_select_id[' + rowID + ']"]');
+        if (cj(this).val() && !contactIdElement.val()) {
           inValidRow++;
           errorExists = true;
         }
+        else if (cj(this).val() && contactIdElement.val()) {
+          // this is hack to remove error span because we are skipping this for autocomplete fields
+          cj(this).next('span.crm-error').remove();
+        }
       }
     }
     else {
@@ -225,7 +230,7 @@ function checkColumns(parentRow) {
         inValidRow++;
       }
       else {
-        if (cj(this).hasClass('error') && !cj(this).hasClass('valid')) {
+        if (cj(this).hasClass('error') && (cj(this).hasClass('valid') || cj(this).hasClass('required'))) {
           errorExists = true;
         }
         else {
-- 
GitLab