From 2723928a255fc344694f4793772e634434ab265c Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Tue, 9 Aug 2016 18:30:48 +0530 Subject: [PATCH] CRM-19171 - handle checkbox and radio when validation fails --- .../Contribute/Form/Contribution/OnBehalfOf.tpl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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; } -- 2.25.1