I have a VF page to make a record for a custom object. It has 2 <pageBlockSection>. The first should always be rendered, and it contains a picklist. Depending on the value of the picklist, the second might be rendered.

What is the best way to go about this? Can the standard controller handle this, or does it need a custom controller? Why isn't my second section rendering correctly?

The picklist:

<apex:inputField value="{!CustomObject__c.Type__c}"> 
     <apex:actionSupport event="onchange" reRender="section2"/>

And the second section:

<apex:pageBlockSection id="section2" columns="1" rendered="{!IF(CustomObject__c.Type__c == 'Functionality Request',true,false)}">  
    <apex:inputField value="{!CustomObject__c.Priority__c }"/>

  • Can you tell if field dependency is already setup in that Object for these fields Type__c & Priority__c ? If yes, standard controller can handle this. Jan 20, 2017 at 21:36
  • 1
    rendered="{!(CustomObject__c.Type__c == 'Functionality Request')}"
    – o-lexi
    Jan 20, 2017 at 21:53
  • I just used Priority as an example. The end result pageBlockSection will have like 5 or 6 fields of all different types in it. Jan 20, 2017 at 21:55
  • Think the point is that = is an assignment whereas == is a comparison.
    – Keith C
    Jan 20, 2017 at 21:56
  • Thanks all. The == is probably an error, but when I put that in, it still doesn't work as expected. Jan 20, 2017 at 21:58

1 Answer 1


A custom controller is not needed. You need to re-render the container holding the component that has the conditional rendering expression.

Here is a working example:

<apex:page standardController="Contact">
<apex:pageBlock id="pb">
        <apex:inputField value="{!Contact.Salutation}"> 
             <apex:actionSupport event="onchange" reRender="pb"/>
    <apex:pageBlockSection id="pbs" rendered="{! Contact.Salutation == 'Mr.' }">  
        <apex:inputField value="{!Contact.Birthdate }"/>

where the Birthdate appears if "Mr." is selected. If you change it to reRender="pbs" it no longer works.

  • Perfect, this works. Thank you. I'm trying to understand why the pageBlockSection doesn't count as a container that can be rerendered and why it needs to be the pageBlock. Any good resources suggested for reading about these nuances? Jan 21, 2017 at 0:52
  • @denvergreene There may be but I don't know of any; re-rendering is one of those "always expect trouble" features. My understanding (that may be wrong is that you always have to re-render the container of the item so its the structure more than the specific tags.
    – Keith C
    Jan 21, 2017 at 10:38

You must log in to answer this question.

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