Are State and Country Picklist supported in Visualforce?
I’m trying to access them on Visualforce for Contact object but only a Textbox is displayed instead of a Dropdown.
My code is:
<apex:page standardController="Contact"> <apex:form > <apex:pageBlock mode="edit"> <apex:pageBlockSection > <apex:inputField value="{!contact.MailingCountry}" /> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
I’ve enabled Country and State Picklist in my org, and it shows perfectly fine in Standard Contact Edit form:
Answer
Sry Found the solution to the question just after entering the Question.
The correct Field that should be referenced in Visualforce page is “MailingCountryCode” instead of “MailingCountry”
<apex:page standardController="Contact">
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageBlockSection >
<apex:inputField value="{!contact.MailingCountryCode}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
This code should work fine.
Attribution
Source : Link , Question Author : VarunC , Answer Author : VarunC