I am re-using a global method to get all the picklist values for my select lists and radio lists:


public List<SelectOption> getFrequencyOptions(){

    List<SelectOption> opts=getPicklistValues(sObjectRFC, 'Frequency__c');
    options.add(new SelectOption('',''));
    String[] options = new String[]{};

    for(SelectOption so : opts)
    return options;

public list<SelectOption> getPicklistValues(SObject obj, String fld)
    list<SelectOption> options = new list<SelectOption>();
    // Get the object type of the SObject.
    Schema.sObjectType objType = obj.getSObjectType(); 
    // Describe the SObject using its object type.
    Schema.DescribeSObjectResult objDescribe = objType.getDescribe();       
    // Get a map of fields for the SObject
    map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap(); 
    // Get the list of picklist values for this field.
    list<Schema.PicklistEntry> values = fieldMap.get(fld).getDescribe().getPickListValues();
    // Add these values to the selectoption list.
    options.add(new SelectOption('', '--None--'));
    for (Schema.PicklistEntry a : values)
         options.add(new SelectOption(a.getLabel(), a.getValue())); 
    return options;

VF Page:

<apex:selectRadio value="{!sObjectRFC.Frequency__c}" id="outMailshot_Frequency__c">
    <apex:selectOptions  value="{!FrequencyOptions}"/>                                                    

the problem is, in the page the list of options is coming out all in one line instead of nicely on several lines as in the left one below which is built the classic way:

enter image description here

Is there something else I need to do in order to have them format as the ones on the left?


Use the layout option on apex:selectRadio. This will determine the appearance of the elements:

  • lineDirection: the values go across the screen (DEFAULT VALUE).
  • pageDirection: the values go down the screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.