CRM-19171 - handle checkbox and radio when validation fails
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 9 Aug 2016 13:00:48 +0000 (18:30 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 9 Aug 2016 13:00:48 +0000 (18:30 +0530)
templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl

index 0914f82f5c15599c959063bcf978654513a254ff..d682c15d7ded3eb2823d1ede5337f33a55cc9992 100644 (file)
 
      if (submittedCID == contactID) {
        $.each(submittedOnBehalfInfo, function(key, value) {
-         $('#onbehalf_' + key ).val(value);
+         //handle checkboxes
+         if (typeof value === 'object') {
+           $.each(value, function(k, v) {
+             $('#onbehalf_' + key + '_' + k).prop('checked', v);
+           });
+         }
+         else if ($('#onbehalf_' + key).length) {
+           $('#onbehalf_' + key ).val(value);
+         }
+         //radio buttons
+         else if ($("input[name='onbehalf[" + key + "]']").length) {
+           $("input[name='onbehalf[" + key + "]']").val([value]);
+         }
        });
        return;
      }