0

I have a picklist with values and I need to display them not as dropdown but as radio-buttons, is there an easy was to do it? Maybe even without a custom controller?

0

I don't think , there is way in salesforce to achieve this. may be some hack in javascript to change the element from picklist to radio.. but again for Javascript you need a custom VF page.. and if there is custom vf page , I would like to go with the apex , vf rather than looking for javascript hack.

0

Looks like no easy way, so my ordinary solution is:

Controller:

public with sharing class MyController {
    public InterviewController(ApexPages.StandardController controller) { }

    private List<SelectOption> getSelectOptions(String fieldName) {
        List<Schema.PicklistEntry> pick_list_values = 
            Account.getSObjectType().getDescribe().fields.getMap().get(fieldName).getDescribe().getPickListValues();

        List<selectOption> options = new List<selectOption>();
        for (Schema.PicklistEntry entry: pick_list_values) {
            options.add(new selectOption(entry.getLabel(), entry.getValue()));
        }
        return options;
    }

    public List<SelectOption> getValues() {
        return getSelectOptions('qty_of_of_facilities_serviced__c');
    }
}

VisualForce:

<apex:selectRadio layout='pageDirection' value='{!account.my_field_picklist__c}'>
    <apex:selectOptions value='{!values}'></apex:selectOptions>
</apex:selectRadio>

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.