-1

While I'm trying to get the dependent picklist as input filed in vf page I'm getting the below error.


Visualforce Error The dependent picklist 'Class' requires its controlling field 'Brand' to be present on the page.


VF Page code:

 <apex:inputField value="{!vehicle.Class__c}"/>       

In My Vehicle__c object there are three fields.

Brand-parent
class-(dependent on Brand)
model-(dependent on class)  

How can I display these fileds on my vf page.

0

1 Answer 1

2

As per the documentation

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.

In your case, Class__c is a dependent picklist and it's controlling field is Brand__c. This means values of Class__c are populated when you select any picklist value from it's parent. And since you haven't included controlling picklist field Brand__c, you're getting an error.

So you must include controlling field in the Visualforce Page. So it should be something like this:

 <apex:inputField value="{!vehicle.Brand__c}"/>
 <apex:inputField value="{!vehicle.Class__c}"/>
2
  • The above thing is working, but it was displaying as text fields. But they are picklist fields in object.
    – Lokesh
    Commented Apr 5, 2017 at 10:15
  • @Lokesh You might have used inputText. Documentation clearly says that, page will give you runtime error. Try adding it's controlling field. Commented Apr 5, 2017 at 10:20

You must log in to answer this question.

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