Print this page

Dependent Picklist Considerations on Visualforce Pages

Knowledge Article Number 000199154
Description Consider the following when using dependent picklists in Visualforce pages:
  • You can mix controlling and dependent fields across various field types, such as picklists, multi-picklists, radio buttons, and checkboxes.
  • There’s a limit of 10 dependent picklist pairs per page. This is totaled across all objects. Thus, you could have five dependent picklists on Account, and five on Contact, but no more. This is hard limit and cannot be increased. However, you can repeat the same pair of dependent picklists, such as in an iterative tag like <apex:repeat>, without counting more than once against your limit.
  • If the user viewing the page has read-only access to the controlling field, a dependent picklist might not behave as expected. In this case, the dependent picklist shows all possible values for the picklist, instead of being filtered on the read-only value. This is a known limitation in Visualforce.
  • Pages must include the controlling field for a dependent picklist. Failing to include the controlling field on the page causes a runtime error when the page displays.

  • Don’t mix inline edit-enabled fields with regular input fields from the same dependency group. For example, don’t mix a standard input field for a controlling field with an inline edit-enabled dependent field:
    <apex:page standardController="Account">
        <apex:form>
            <!-- Don't mix a standard input field... -->
            <apex:inputField value="{!account.Controlling__c}"/>
            <apex:outputField value="{!account.Dependent__c}">
                <!-- ...with an inline-edit enabled dependent field -->
                <apex:inlineEditSupport event="ondblClick" />
            </apex:outputField>
        </apex:form>
    </apex:page>
  • If you combine inline edit-enabled dependent picklists with Ajax-style partial page refreshes, refresh all fields with dependent or controlling relationships to each other as one group. Refreshing fields individually isn’t recommended and might result in inconsistent undo/redo behavior. Here’s an example of the recommended way to partially refresh a form with inline edit-enabled dependent picklists:
    <apex:form>
        <!-- other form elements ... -->
    
        <apex:outputPanel id="locationPicker">
            <apex:outputField value="{!Location.country}"> 
                <apex:inlineEditSupport event="ondblClick" /> 
            </apex:outputField>
            <apex:outputField value="{!Location.state}"> 
                <apex:inlineEditSupport event="ondblClick" /> 
            </apex:outputField>
            <apex:outputField value="{!Location.city}"> 
                <apex:inlineEditSupport event="ondblClick" /> 
            </apex:outputField>
        </apex:outputPanel>
        <!-- ... -->
        <apex:commandButton value="Refresh Picklists" reRender="locationPicker" />
    </apex:form>
    All of the inline edit-enabled picklists are wrapped in the <apex:outputPanel> component. The <apex:outputPanel> rerenders when the <apex:commandButton> action method fires.




promote demote