Skip to main content
mac admin ha preguntado en #Visualforce
Hi everyone,

I want to display the Gender selection with radio buttons as shown in below image in Custom object

radio button in custom object

Can anyone help me over here.

Thanks in advance.

Regards,

Bhargav.
2 respuestas
  1. 14 jun 2016, 5:52
    Hi Krishna,

    You can't create a Radio button through Configuration in the model. If you want radio buttons, you need to customize your standard page using APEX. Here is the sample example for the radio button. Based on your requirement you can change the names.

    Visualforce Page:

     

    <apex:page controller="sampleCon">

    <apex:form >

    <apex:selectRadio value="{!country}">

    <apex:selectOptions value="{!items}"/>

    </apex:selectRadio><p/>

    <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>

    </apex:form>

    <apex:outputPanel id="out">

    <apex:actionstatus id="status" startText="testing...">

    <apex:facet name="stop">

    <apex:outputPanel >

    <p>You have selected:</p>

    <apex:outputText value="{!country}"/>

    </apex:outputPanel>

    </apex:facet>

    </apex:actionstatus>

    </apex:outputPanel>

    </apex:page>

    Controller:

     

    public class sampleCon {

    String country = 'CANADA';

    public PageReference test() {

    return null;

    }

    public List<SelectOption> getItems() {

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

    options.add(new SelectOption('US','US'));

    options.add(new SelectOption('CANADA','Canada'));

    options.add(new SelectOption('MEXICO','Mexico')); return options;

    }

    public String getCountry() {

    return country;

    }

    public void setCountry(String country) { this.country = country; }

    }

    Hope this helps you!

    Best Regards,

    Jyothsna
0/9000