2

Question

Can a Visualforce Page be built so it displays the actual picklist values and dependencies for fields which incorporate State and Country Picklists? I tried using Field Sets as well as hard-coded field references, and either way it just displays a text input.

MVR Markup

<apex:page standardController="Account">
    <apex:form>
        <apex:pageBlock>
            <apex:pageBlockSection>
                <apex:inputField value="{!Account.BillingStreet}" />
                <apex:inputField value="{!Account.BillingCity}" />
                <apex:inputField value="{!Account.BillingState}" />
                <apex:inputField value="{!Account.BillingPostalCode}" />
                <apex:inputField value="{!Account.BillingCountry}" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Screenshot

BillingAddress inputFields

The edit page displays the picklist as expected:

BillingAddress detail

  • Bold formatting seems to have disappeared... – Adrian Larson Nov 15 '17 at 19:50
  • 2
    Try using the corresponding code field e.g. {!Account.BillingStateCode} - I think that presents the picklist values. – Keith C Nov 15 '17 at 20:51
  • @Keith The field labels on the edit page hint as much. Good idea, and it worked. Post as an answer and I will accept. – Adrian Larson Nov 15 '17 at 20:54
  • Done. Couldn't find any mention of that in the docs though. – Keith C Nov 16 '17 at 8:45
2

Using the corresponding code field in the Visualforce e.g. {!Account.BillingStateCode} instead of {!Account.BillingState}will present the picklist values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.