How to format a lookup field from within a template

I am a fan of using both the Field Renderer and Display Template to give context.

<field id="Business_State__c" type="REFPICK" displaytemplate="{{Name}} {{State_Code_c__c}}">
 <filters/>
</field>

This gives me a great picklist that shows the state code and also the full state name.

This field features in a template:

<field type="COMBO" allowhtml="false">
 <label>{{$Label.Business_Address}}</label> <template>{{Business_Address_1__c}} {{Business_Address_2__c}} {{Business_Address_3__c}} {{Business_City__c}} {{Business_State__c}} {{Business_Zip_Postal_Code__c}} {{Business_Country2__c}} </template> </field>

Which looks like this:

  1. Can I include the picklist formatting from the first example in the template?
  2. If so, can the picklist (with the 2 field Display Template) only appear on the popup, and not on the read layout?
  3. Can the lines that are missing in the above example not show on the read layout?

Well hello there Ross …

On your point 3. We do something similar by using a bit more Mustache syntax like this:

{{#Business_Address_2__c}}{{Business_Address_2__c}}{{/Business_Address_2__c}}

which basically says “if Business_Address_2__c exists, then render it”.

To get all the line breaks and spaces just right, we have HTML and Mustache in our address template like this:

{{#ShippingCity}}
    <div>Location Address</div>
    <div>{{#ShippingStreet}}{{ShippingStreet}}{{/ShippingStreet}}</div>
    <div>{{ShippingCity}} {{#ShippingState}}{{ShippingState}} {{/ShippingState}}{{ShippingPostalCode}}</div>
    {{#ShippingCountry}}<div>{{ShippingCountry}}</div>{{/ShippingCountry}}
{{/ShippingCity}}

Hey, Ross,
Glenn’s advice is good for conditionally displaying certain fields. Unfortunately, there is no way to control how fields render in the template popup currently. I think it would be a great idea, though (and I think other customers would agree)! You should suggest it in our community.
Emily

Good news! I just found out that Skuid’s Summer 14 release will allow you to customize the edit popup on template fields! Yay!

Hello Glenn!

Thanks for this. With the news from Emily on soon being able to edit the popup, this may just be the ticket!

Hi Emily

This is very good news indeed. Can’t wait!