From: jitendrapurohit Date: Tue, 9 Aug 2016 13:00:48 +0000 (+0530) Subject: CRM-19171 - handle checkbox and radio when validation fails X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2723928a255fc344694f4793772e634434ab265c;p=civicrm-core.git CRM-19171 - handle checkbox and radio when validation fails --- diff --git a/templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl b/templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl index 0914f82f5c..d682c15d7d 100644 --- a/templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl +++ b/templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl @@ -131,7 +131,19 @@ 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; }