I have a simple page with a form that is supposed to create a custom object. This custom object has several picklist fields. I can dynamically populate the selectLists, but when I give the selectList the object's picklist value, it disappears from the page.
What I have on the page:
<apex:selectList value="{!sa.Machine__c}" multiselect="false" label="Machine" size="1">
<apex:selectOptions value="{!machineOptions}"/>
</apex:selectList>
In my controller:
public Change__c sa { get; set; }
public Controller() {
sa = new Change__c();
prePopulateOptions();
}
private void prePopulateOptions() {
machineOptions = populateOptions(Change__c.Machine__c.getDescribe());
}
private List<SelectOption> populateOptions(Schema.DescribeFieldResult fieldDescription) {
List<SelectOption> options = new List<SelectOption>();
// For each picklist value, create a new select option
for (Schema.Picklistentry picklistEntry: fieldDescription.getPicklistValues()){
options.add(new SelectOption(pickListEntry.getValue(),pickListEntry.getLabel()));
}
return options;
}
If I remove the selectList value, or change the value to a String object, it shows the selectList on the page. But it does not now.
Ultimately, I just want a convenient way to upsert the sa object.