This is a continuation of this other thread, but I’m reposting because I’m in a hurry and the other thread was marked ‘Answered’ for some reason.
Simplified use case:
Everywhere the ui finds a picklist field called Primary_Phone_Type__c, run a custom field renderer snippet called “renderPhoneTypes”
Everywhere the ui finds a picklist field called STD__c, run a custom field renderer called “renderSTDs”
Etc.
I have an inline static resource which includes this code:
// Get references to our original picklist field renderers var fieldRenderers = skuid.ui.fieldRenderers; <br>var PICKLIST = fieldRenderers.PICKLIST;<br>// My custom Phone field renderer<br>var checkPicklistRenderer = function(field, value) {<br>//Object as switch statement<br>var globalPickFields = {<br>'Case_Type__c': 'renderCaseTypes',<br>'Primary_Phone_Type__c': 'renderPhoneTypes',<br>'Alternate_Phone_Type__c': 'renderPhoneTypes',<br>'Interaction_Intention__c': 'renderPregnancyIntentions',<br>'Pregnancy_Intention__c': 'renderPregnancyIntentions',<br>'Pregnancy_Intention_on_Intake__c': 'renderPregnancyIntentions',<br>'Father_of_the_Baby_Intention__c': 'renderPregnancyIntentions',<br>'Role__c': 'renderStaffRoles',<br>'Primary_Staff_Role__c': 'renderStaffRoles',<br>'Additional_Staff_Role__c': 'renderStaffRoles',<br>'STD__c': 'renderSTDs',<br>'Sexual_Exposure_to_What_STD__c' : 'renderSTDs',<br>'STD_Picklist': 'renderSTDs',<br>'Referral_Source__c': 'renderReferralSources',<br>'Results__c': 'renderPregnancyTestResults',<br>};<br>// If the field is one of the global picklist fields, run the snippet for it<br>if (globalPickFieldsgfield.id]){<br>skuid.snippet.getSnippet(globalPickFieldsgfield.id])(field,value);<br><b>//*** PROBLEM : when snippets attempt to call standard renderer in edit mode <br></b><b> // they get this checkPicklistRenderer again. Infinite loop.<br></b>} else { //Otherwise run the standard renderer<br>PICKLISTtfield.mode](field,value);<br><b>//*** PROBLEM : infinite loop<br></b> }<br>};<br> <b>// Override all of Skuid's standard Picklist field renderers to call our custom renderer<br></b> PICKLIST.edit = function(){<br> checkPicklistRenderer.apply(this,arguments);<br> };