You need to sign in to do that
Don't have an account?
Compile Error on Extension
I am trying to figure out why this is not compling corrrectly. The error I recieve is: "Error: Compile Error: Constructor not defined: [System.SelectOption].<Constructor>(Id) at line 14 column 25." Would appreciate it if you guys could help a new developer out.
Chris
public class ModalityExtension {
private Trade_in__c t; //User sobject
public ModalityExtension(ApexPages.StandardController stdController) {
this.t = (Trade_in__c)stdController.getRecord();
}
public List<selectOption> getModality() {
List<selectOption> options = new List<selectOption>(); //new list for holding all of the picklist options
options.add(new selectOption('', '- None -')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below
for (Trade_in__c TradeIns : [SELECT Modality2__c FROM Trade_in__c]) {
options.add(new selectOption(TradeIns.Modality2__c)); //for all records found - add them to the picklist options
}
return options; //return the picklist options
}
}
I believe this line of code is failining
You need to pass at least two strings to create a new selectoption.
Check out the selectoption apex class here