+ Start a Discussion
Sai Bharathwaj SureshbabuSai Bharathwaj Sureshbabu 

how to show picklist field as Radio button on Visualforce Page, where picklist field have five values

Vinod ChoudharyVinod Choudhary

Use following methods to get options for radio button on page

public List<SelectOption> getTypesPicklist(){
            Schema.sObjectType sobject_type = customObject__c.getSObjectType();

            Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();

            Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
            List<Schema.PicklistEntiris> picklistvalues = field_map.get('type__c').getDescribe().getPickListValues();

            List<selectOption> options = new List<selectOption>();

           for (Schema.PicklistEntiris a : picklistvalues) {
                      options.add(new selectOption(a.getLabel(), a.getValue()));
      return options;

to use this on the page:
<apex:selectRadio value="{!customObject__c.Type__c}">
                    <apex:selectoptions value="{!types}"></apex:selectoptions>

hope this will help.