function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andrew Hoban 6Andrew Hoban 6 

Making a Radio Button a Default Value from Picklist

Hi all,

I have created radio buttons that uses a Picklist field. Is there a way of maing one of the values default? 

I need the 'Not Required' value to be default.

Many thanks
<apex:page standardController="Everton_Users__c" showHeader="true"  >
<apex:sectionHeader title="Everton Users"
                 subtitle="New Everton User"/>
<apex:form >
<apex:pageblock mode="edit"  >
 <apex:pageBlockButtons location="both">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>

<apex:pageBlockSection title="Information" columns="2">
 <apex:inputField value="{!}" Required="True"/>
 <apex:inputField value="{!Everton_Users__c.Start_Date__c}"/>

 <apex:pageblockSection title="ITSS Signed Policies" columns="1" >
 <apex:inputField value="{!Everton_Users__c.ITSS_Acceptable_Usage_Policy__c}"/>


<apex:pageblockSection title="Equipment Control" columns="2"  >
        <apex:selectRadio label="Sharefile:" value="{!Everton_Users__c.Sharefile__c}" required="true" style="margin-top: -10px;">
        <apex:selectOption itemLabel="Not Required" itemvalue="Not Required"/>
        <apex:selectOption itemLabel="Required" itemvalue="Required"/>
        <apex:selectOption itemLabel="Enabled" itemvalue="Enabled"/>
        <apex:selectOption itemLabel="Disabled" itemvalue="Disabled"/>

Best Answer chosen by Andrew Hoban 6

All Answers

Frédéric TrébuchetFrédéric Trébuchet

You have to prepopulate the field value before to display the selectRadio using a setter.
Here is an example

Andrew Hoban 6Andrew Hoban 6
Thank you for the reply. In the example you have provided, is this using a picklist field or is it just values they have created inside the controller?

Ideally I would like the radio buttons to work off the picklist (safarefile) I have created. Thanks

Frédéric TrébuchetFrédéric Trébuchet
As you can see, values are provided by the controller (hard coded).
I'm not sure to understand exactly what you'd like to do.
To retrieve picklist values have a look here
Andrew Hoban 6Andrew Hoban 6
Thanks for this.

I am basically trying to change the view of a picklist to radio buttons. This has been achieved, however when the page first loads I wish not required to be selected. I have done this in a controller similar to the first example however that was not related to a picklist and its values. I am unsure how to relate the piklist and its values in a controller/

Im sorry if I am not making sense.

Frédéric TrébuchetFrédéric Trébuchet
This was selected as the best answer
Andrew Hoban 6Andrew Hoban 6
Thank you this is what will work for me. I just need to work out how to do it now haha!

Thank you
Frédéric TrébuchetFrédéric Trébuchet
Kindly mark the more helpfull answer as the best one and mark the question as Solved.