Salesforce Asked by cw-DEO on November 15, 2021
I have a custom object called Program__c
which has a picklist called Categories__c
.
I would like to make a dropdown list on my VF page that merely lists the contents of the picklist.
My VF page has
<apex:selectList value="{!category}" size="1" multiselect="false" styleClass="pickList" required="true">
<apex:selectOptions value="{!categoryList}"/>
<apex:actionSupport event="onchange" action="{!saveCategoryValue}" />
</apex:selectList>
What is selected will be written to another custom object along with other items. Currently, saveCategoryValue
doesn’t do anything. I figured I needed to make the list show up before worrying about saving the selected value.
My controller has
public List<SelectOption> getcategoryList()
{
Schema.DescribeFieldResult statusFieldCategory = Program__c.Categories__c.getDescribe(); // good
List<Program__c> categories = [select id, Categories__c from Program__c]; // get the values from the Program__c object
List<SelectOption> categoryList= new List<SelectOption> (); // create the list
for (Schema.Picklistentry picklistEntry : statusFieldCategory.getPicklistValues())
{
// put picklist values into an <apex:selectOptions> tag for VF display
categoryList.add(new SelectOption(pickListEntry.getValue(),pickListEntry.getLabel()));
}
return categoryList;
}
When I preview the VF the drop down is empty.
At the top I have category declared as a string and I think somehow I need to put the selected value in category so that I can save it. Before that I need to see the values.
I’m not understanding this, obviously. What is wrong here?
Thanks for you help!
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP