You need to sign in to do that
Don't have an account?
![Lago S.p.a. Lago S.p.a.](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Current Picklist of record does not show in visualforce
Hi experts!
I have a little problem with a simple force.com site that I'm building.
I want to see a list of contacts with basic info, one of these info is a picklist field, but when I render the page, this picklist show the first value of list instead of the current value of the record.
Here's my VF Code of the picklist:
VF
<apex:pageBlockSectionItem >
<apex:outputLabel value="{!$ObjectType.Contact.fields.type__c.label}" />
<apex:selectList styleClass="slds-input" value="{!statusOptions}" size="1">
<apex:selectOptions value="{!ItemsList}" rendered="true"/>
</apex:selectList>
</apex:pageBlockSectionItem>
And the method of the controller:
public List<Selectoption> getItemsList(){
List<SelectOption> options = new List<SelectOption>();
List<Schema.Picklistentry> fieldResult = Schema.Contact.type__c.getDescribe().getPicklistValues();
//options.add(new SelectOption());
for(Schema.PicklistEntry f : fieldResult) {
options.add(new SelectOption(f.getValue(), f.getLabel()));
}
return options;
}
Any help will be very appreciated! Thanks in advance.
I have a little problem with a simple force.com site that I'm building.
I want to see a list of contacts with basic info, one of these info is a picklist field, but when I render the page, this picklist show the first value of list instead of the current value of the record.
Here's my VF Code of the picklist:
VF
<apex:pageBlockSectionItem >
<apex:outputLabel value="{!$ObjectType.Contact.fields.type__c.label}" />
<apex:selectList styleClass="slds-input" value="{!statusOptions}" size="1">
<apex:selectOptions value="{!ItemsList}" rendered="true"/>
</apex:selectList>
</apex:pageBlockSectionItem>
And the method of the controller:
public List<Selectoption> getItemsList(){
List<SelectOption> options = new List<SelectOption>();
List<Schema.Picklistentry> fieldResult = Schema.Contact.type__c.getDescribe().getPicklistValues();
//options.add(new SelectOption());
for(Schema.PicklistEntry f : fieldResult) {
options.add(new SelectOption(f.getValue(), f.getLabel()));
}
return options;
}
Any help will be very appreciated! Thanks in advance.
With
<apex:selectList styleClass="slds-input" value="{!Contact.Type__c}" size="1">
It will show the contact record type value.