Print this page

Dependent picklists do not work correctly when using inline editing on a Visualforce page

Knowledge Article Number 000175208
Description

You have a dependent picklist on a Visualforce page that doesn't behave as expected.  The following example code illustrates the typical problem:

<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock mode="edit">

            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons> 
         
            <apex:pageBlockSection title="Dependent Picklists" columns="2">
             <apex:outputField value="{!account.type}"/>           
            </apex:pageBlockSection>

            <apex:pageBlockSection >
             <apex:inlineEditSupport showOnEdit="harsh"/>
             <apex:outputField value="{!account.Fruit_Picklist__c}" id="harsh"/>
            </apex:pageBlockSection>

        </apex:pageBlock>
    </apex:form>
</apex:page>

Resolution

Inline editing on dependent picklists referenced on the Visualforce page will only work when the picklists are placed in the same <apex:pageBlockSection >. In case you place a dependent picklist in a different <apex:pageBlockSection>, inline editing will not function correctly.

Refer to the sample code below as the correction to the example page listed above.

<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock mode="edit">

            <apex:pageBlockButtons >
             <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>  
        
            <apex:pageBlockSection title="Dependent Picklists" columns="2">
             <apex:outputField value="{!account.type}"/>           
             <apex:inlineEditSupport showOnEdit="harsh"/>
             <apex:outputField value="{!account.Fruit_Picklist__c}" id="harsh"/>
            </apex:pageBlockSection>

        </apex:pageBlock>
    </apex:form>
</apex:page>





promote demote