1

Sorry, I am a newbie in salesforce.

I searched all over the internet, and found only how to create a custom VF page with Radio Buttons, but I cannot figure out how to add it to my custom object. I have a picklist which I need to replace with radio buttons. My custom project is called 'Pre_propo__c'. I do not know either I need to link this VF component to already existing standard component (picklist), or how to define it unlinked to any picklist in the object. When I place place this component on the object layout I do not see anything when I create a record.

Please, help.

VF:

<apex:page standardController="Pre_propo__c">
    <apex:form >
        <apex:selectRadio value="{!Pre_propo__c.Research_Cluster_2__c}">
            <apex:selectOption itemLabel="Public" itemValue="Public"/>
            <apex:selectOption itemLabel="Private" itemValue="Private"/>    
            <apex:selectOption itemLabel="Subsidiary" itemValue="Subsidiary"/>    
            <apex:selectOption itemLabel="Other" itemValue="Other"/>        
        </apex:selectRadio>
    </apex:form>
</apex:page>

Layout:

enter image description here

Record creation:

enter image description here

Thanks

1

For this to work you'll need to commit the selections. Currently your page just displays the radio buttons, but changing the values doesn't go to the database. For this you'll need to use the save method.

<apex:page standardController="Pre_propo__c">
    <apex:form >
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:selectRadio value="{!Pre_propo__c.Research_Cluster_2__c}">
            <apex:selectOption itemLabel="Public" itemValue="Public"/>
            <apex:selectOption itemLabel="Private" itemValue="Private"/>    
            <apex:selectOption itemLabel="Subsidiary" itemValue="Subsidiary"/>    
            <apex:selectOption itemLabel="Other" itemValue="Other"/>        
        </apex:selectRadio>
    </apex:form>
</apex:page>

That said, what you're going for - replacing a standard input field with a modified input method - isn't easy. If you continue with your approach you'll be close, but it means that a user will A) only be able to see/use the radio button on the "view" page and B) will have to remember to click the save button in the inline visualforce page (not the standard save button) to store any changes. You can override the new and edit pages with your own page, but then you have to create the rest of the layout as well.

One option would be to make that field read only on the page layout. Then add a button linked to your current page called "Change Research Cluster". The user clicks the button, changes the research cluster, clicks save, and goes back to the Pre Propo record. Not ideal, but less error prone.

In any event, the requirement, display a picklist as a radio button, may not be worth the effort.

  • Ralph thank you for you response. 1. So, it is not possible to create a radio button with VF (and apex), and to use it in custom object ? 2. I made the change you suggested. However, I still do not see radio buttons when I drug VisualForce component to layout. It does not show up when I create a new record. – vlr May 7 '13 at 0:12
  • I also tried to use this as an example, but could not figure out how to use it in my custom object: salesforce.com/us/developer/docs/pages/Content/… – vlr May 7 '13 at 0:30
  • Adding it to the layout only applies to the "view" page. Unfortunately you can't add visualforce page to the "edit" or "new" page without doing a full override. Updating my answer to reflect that. – Ralph Callaway May 7 '13 at 1:54

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.