CRM-13966 - Fix pcp autocomplete default
authorColeman Watts <coleman@civicrm.org>
Sun, 23 Mar 2014 20:00:08 +0000 (16:00 -0400)
committerColeman Watts <coleman@civicrm.org>
Sun, 23 Mar 2014 20:00:08 +0000 (16:00 -0400)
templates/CRM/Contribute/Form/SoftCredit.tpl

index f45897e4a49c4f9993b860bb55c4cc2e82cc65d2..5b8624dd0bb9fc6e1de82477cdbb2b4fa7fd7442 100644 (file)
@@ -67,6 +67,7 @@
 {literal}
 <script type="text/javascript">
   cj(function($) {
+    var $form = $("#{/literal}{$form.formName}{literal}");
     $('#showPCP, #showSoftCredit').click(function(){
       return showHideSoftCreditAndPCP();
     });
         }
       },
       initSelection: function(el, callback) {
-        callback({id: $(el).val(), text: $('#pcp_made_through').val()});
+        callback({id: $(el).val(), text: $('[name=pcp_made_through]', $form).val()});
       }
-    });
+    })
+      // This is just a cheap trick to store the name in case of a formrule error
+      .on('change', function() {
+        console.log($(this).select2('data'));
+        $('[name=pcp_made_through]', $form).val($(this).select2('data').text || '');
+      });
 
     $('.crm-soft-credit-block tr span').each(function () {
       if ($(this).hasClass('crm-error')) {