You need to sign in to do that
Don't have an account?

How to set a default value to a Radio Button?
How do I give my radio buttons a value that has already been detarmined in a picklist?

Example if I choose "Male" in my picklist I would like the "Male" radio button to be selected on my VF page.
Also,
how do I use a checkbox with a value of TRUE & FALSE and convert it into a radio button saying yes and no?

Thanks Dan
Example if I choose "Male" in my picklist I would like the "Male" radio button to be selected on my VF page.
Also,
<div class="slds-size_2-of-8"> <div class="slds-box slds-box_x-small slds-text-align_center slds-m-around_x-small"> <div class="slds-form-element__control"> <label class="slds-form-element__label" for="form-element-02"> <b> Are You British Citizen?:- </b> </label> <span class="slds-radio"> <input type="radio" id="radio-3" value="radio-" name="YesNo" /> <label class="slds-radio__label" for="radio-3"> <span class="slds-radio_faux"> </span> <span class="slds-form-element__label"> Yes </span> </label> </span> <span class="slds-radio"> <input type="radio" id="radio-4" value="radio-4" name="YesNo" /> <label class="slds-radio__label" for="radio-4"> <span class="slds-radio_faux"> </span> <span class="slds-form-element__label"> No </span> </label> </span> </div> {! Apprentice__c.British_Citizen__c} </div> </div>
how do I use a checkbox with a value of TRUE & FALSE and convert it into a radio button saying yes and no?
<div class="slds-size_2-of-8"> <div class="slds-box slds-box_x-small slds-text-align_center slds-m-around_x-small"> <div class="slds-form-element__control"> <label class="slds-form-element__label" for="form-element-01"> <b> Gender </b> </label> <span class="slds-radio"> <input type="radio" id="radio-1" value="{! Apprentice__c.Gender__c}" name="MaleFemale"/> <label class="slds-radio__label" for="radio-1"> <span class="slds-radio_faux"> </span> <span class="slds-form-element__label"> Male </span> </label> </span> <span class="slds-radio"> <input type="radio" id="radio-2" value="{! Apprentice__c.Gender__c}" name="MaleFemale" /> <label class="slds-radio__label" for="radio-2"> <span class="slds-radio_faux"> </span> <span class="slds-form-element__label"> Female </span> </label> </span> </div> </div> </div>
Thanks Dan
Step 2 : Get the Currect Selected valule from the Object .. You can use SOQL to get the value and set to the attribute
Step 3 : Do the aura:iteration to loop the values from the picklist
Step 4 : Use select option select to true if the picklist value is matched the data form the record
All Answers
Step 2 : Get the Currect Selected valule from the Object .. You can use SOQL to get the value and set to the attribute
Step 3 : Do the aura:iteration to loop the values from the picklist
Step 4 : Use select option select to true if the picklist value is matched the data form the record
Below code can fullfill your requirements. Hope this will work for you.
VF page :
<apex:page controller="sampleCon">
<apex:form>
<apex:selectRadio value="{!Gender}">
<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="{!Gender}"/>
</apex:outputPanel>
</apex:facet>
</apex:actionstatus>
</apex:outputPanel>
</apex:page>
Controller :
public class sampleCon {
String Gender = null;
public PageReference test() {
return null;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('Male','Male'));
options.add(new SelectOption('Female','Female'));
return options;
}
public String getGender() {
return Gender;
}
public void setGender(String Gender) { this.Gender = Gender; }
}
Please mark as best answer if it helps you.
Thank You
Ajay Dubedi