14

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: enter image description here

2
  • Thnx for the Editing @Ralph. Next time I'll keep in mind these corrections.
    – VarunC
    Commented Nov 5, 2013 at 12:54
  • Happy to help @varun. Picture was very helpful, an excellent inclusion. Commented Nov 5, 2013 at 17:48

1 Answer 1

14

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.

1
  • Same thing for MailingStateCode instead of MailingState Commented Mar 2, 2017 at 16:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .