APIExplorer - allow entering an id in entityRef
authorColeman Watts <coleman@civicrm.org>
Fri, 28 Aug 2015 20:47:42 +0000 (16:47 -0400)
committerColeman Watts <coleman@civicrm.org>
Sat, 29 Aug 2015 00:49:25 +0000 (20:49 -0400)
templates/CRM/Admin/Page/APIExplorer.js

index b2aeb0877d4e549c9107c344433ce534034268e0..ffac1c32407f9660d523b53ed186984df6f1be2b 100644 (file)
           entity: entity,
           select: {
             multiple: multiSelect,
-            minimumInputLength: _.includes(OPEN_IMMEDIATELY, entity) ? 0 : 1
+            minimumInputLength: _.includes(OPEN_IMMEDIATELY, entity) ? 0 : 1,
+            // If user types a numeric id, allow it as a choice
+            createSearchChoice: function(input) {
+              var match = /[1-9][0-9]*/.exec(input);
+              if (match && match[0] === input) {
+                return {id: input, label: input};
+              }
+            }
           }
         });
       }