Copy Clear value in batch update process for radio button field
authorSunil Pawar <sunil@skvare.com>
Mon, 14 Mar 2022 08:31:56 +0000 (14:01 +0530)
committerSunil Pawar <sunil@skvare.com>
Mon, 14 Mar 2022 08:31:56 +0000 (14:01 +0530)
templates/CRM/common/batchCopy.tpl

index a1b120161991c39d09a445fff28b36f6e6aaff2d..ee41fefde457fdfad26eb83debb8d54e40c7cc5a 100644 (file)
       // select, checkbox, radio, date fields, text, textarea, multi-select
       // wysiwyg editor, advanced multi-select ( to do )
       if ( elementType == 'radio' ) {
-        firstElementValue = elementId.filter(':checked').eq(0).val();
-        elementId.filter("[value='" + firstElementValue + "']").prop("checked",true).change();
+        var firstElementId    = $('.crm-copy-fields tr:first-child [name^="field["][name*="[' + fname +']"][type!=hidden]');
+        firstElementValue = firstElementId.filter(':checked').eq(0).val();
+        // if radio button is uncheck then unset all the fields.
+        if (typeof firstElementValue == 'undefined') {
+          elementId.prop("checked", false).change().siblings('a.crm-clear-link').trigger('click');
+        }
+        else {
+          elementId.filter("[value='" + firstElementValue + "']").prop("checked", true).change();
+        }
       }
       else if ( elementType == 'checkbox' ) {
         // handle checkbox