0

I have a VF page which uses a custom controller SearchController. The VF page a has component TempCmp. In the component TempCmp, I am trying to use dependent picklists using apex:inputField.

It throws the following error:

The dependent picklist 'Dependent Pick List' requires its controlling field 'Controlling Pick list 1' to be present on the page.

VF page

<apex:page controller="SearchController">
    This is page    
    <c:TempCmp leadVariable="{!patient}"></c:TempCmp>    
</apex:page>

Custom Controller:

global with sharing class SearchController { 
    public Lead patient  {get; set;}
}

Component:

<apex:component >
    <apex:attribute name="leadVariable" description="Object Variable" type="Lead"  />
    <apex:form >
        <apex:pageBlock> 
            <apex:inputField value="{!leadVariable.Controlling_Pick_list_1__c}"/>
            <apex:inputField value="{!leadVariable.Dependent_Pick_List__c}"/>
        </apex:pageBlock>
    </apex:form> 
</apex:component>

Is there any way to resolve this issue using VF component?

2
  • on change of Controlling_Pick_list_1__c rerender the Dependent_Pick_List__c it's parent component then it reflect on VF page
    – Ratan Paul
    Aug 29, 2017 at 10:02
  • The VF page throws the error on load.
    – Ankita
    Aug 29, 2017 at 10:04

1 Answer 1

2

You need to be initialize the Lead patient object in SearchController , because of that your facing the issue.

global with sharing class SearchController { 
        public Lead patient  {get; set;}
        public SearchController () {
        patient = new lead();
        }
 }

You must log in to answer this question.

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