+ Start a Discussion

VF page Picklist inputField onchange apex method not executed required fields exist.

We have a custom object that has fields that should only be visible based on a custom select or a picklist. When the Custom Object fields are required or an inputField is marked as required the onchange event does not execute. Adding immediate="true" to the actionFunction also doesn't allow the onchange to execute.


Using the built in Account object also produces the same result. The desired result for this example is to hide the Billing City field when Web is selected from the picklist. This works until the accountName section, which contains a required field, is uncommented then the field is not hidden when Web is selected. Is there a missing attribute or additional setting required?





<apex:page controller="AccountTest">
  <apex:form >
      <apex:pageBlock >
            <apex:actionFunction action="{!getSelection}" rerender="accountName" name="callSelection"/>
            <apex:pageBlockSection title="Account Information" id="testing" Columns="1">                
                <apex:inputField id="accountSource" value="{!account.AccountSource}" onchange="callSelection(this.value);"/>
           <apex:pageBlockSection columns="1" id="accountName">
                <apex:inputField value="{!account.BillingCity}" rendered="{!isVisible}"/>
           <!--***Comment Out This Section***-->
           <apex:pageBlockSection title="Account Name" id="accountName" columns="1" >
                <apex:inputField value="{!account.Name}" rendered="{!isVisible}"/>
           <!--***Comment Out This Section***-->



public class AccountTest {
    public Account account {get;set;}
    public AccountTest(){
        this.account = new Account();
    public boolean getIsVisible(){
        return Account.AccountSource != 'Web';
    public PageReference getSelection()
        Account.BillingCity =  Account.AccountSource;
        return null;