Hi All,
Need to save the selected radio button value into custom object.
If I select "Excellent" radio button and click submit button. Need to save Excellent value into custom object. But my code is not save the value into custom object. Below is my code and please suggest where i am doing wrong.
1) VF Code:
--------------------------------------------
<apex:page controller="RadioBtn_table_Apex" showHeader="false" applyHtmlTag="true" applyBodyTag="false">
<style>
.fswrapper{
width:800px;
margin:0 auto;
border:3CCF4E 30px;
}
.headerTitle
{
font-family:arial,sans-serif;
font-size:16px;
font-weight:600;
color: #fff!important;
text-align:left;
text-transform:UPPERCASE;
background: #4e75a3;
Padding:10px;
display:block;
margin:0;
}
input[type=radio] {margin-left: 40px;}
.radioClass {margin-left: 5%;}
.big {line-height: 2.8;}
</style>
<apex:form styleClass="fswrapper" id="frm">
<head>
<apex:slds />
</head>
<center>
<img src="{!$Resource.ForceDotCom}"/>
</center>
<apex:pageBlock >
<h1 class="headerTitle"> Application Feedback </h1>
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Submit" action="{!savefeedback}" reRender="frm"/>
<apex:commandButton value="Exit" action="{!feedbackexit}" reRender="frm"/>
</apex:pageBlockButtons>
<!--
<apex:selectRadio>
<apex:selectOption itemLabel="Excellent" itemValue="Excellent" value="{!ratobj.Application_Rating__c}"/>
<apex:selectOption itemLabel="Great" itemValue="Great" value="{!ratobj.Application_Rating__c}"/>
<apex:selectOption itemLabel="Good" itemValue="Good" value="{!ratobj.Application_Rating__c}"/>
<apex:selectOption itemLabel="Medium" itemValue="Medium" value="{!ratobj.Application_Rating__c}"/>
<apex:selectOption itemLabel="Poor" itemValue="Poor" value="{!ratobj.Application_Rating__c}"/>
<apex:selectOption itemLabel="Very Bad" itemValue="Very Bad" value="{!ratobj.Application_Rating__c}"/>
</apex:selectRadio> -->
<apex:actionRegion >
<Table width="100%" border="0" cellpadding="0" cellspacing="0" columns="0" >
<tr >
<td colspan="5" class="fieldLabel">
<p style="font-size: 20px;">
<b> How likely are you with our Application </b>
</p>
<!-- <apex:selectRadio value="{!RB_Rating__c.Application_Rating__c}" styleClass="radioClass" layout="pageDirection"> -->
<apex:selectRadio id="selectRb">
<apex:selectOption itemLabel="Excellent" itemValue="Excellent">
<!-- <apex:image url="{!$Resource.Smiley}"/> -->
</apex:selectOption>
<apex:selectOption itemLabel="Great" itemValue="Great" value="{!ratobj.Application_Rating__c}"/>
<apex:selectOption itemLabel="Good" itemValue="Good" value="{!ratobj.Application_Rating__c}"/>
<apex:selectOption itemLabel="Medium" itemValue="Medium" value="{!ratobj.Application_Rating__c}"/>
<apex:selectOption itemLabel="Poor" itemValue="Poor" value="{!ratobj.Application_Rating__c}"/>
<apex:selectOption itemLabel="Very Bad" itemValue="Very Bad" value="{!ratobj.Application_Rating__c}"/>
</apex:selectRadio>
</td>
</tr>
</Table>
</apex:actionRegion>
</apex:pageBlock>
</apex:form>
</apex:page>
2) Apex Code :
----------------------------
public class RadioBtn_table_Apex
{
public RB_Rating__c ratobj{get;set;}
public RadioBtn_table_Apex()
{
ratobj = new RB_Rating__c();
}
public pagereference savefeedback()
{
insert ratobj;
return Auth.SessionManagement.FinishLoginflow('/'+ratobj.Id);
}
public pagereference feedbackexit()
{
return Auth.SessionManagement.FinishLoginflow('/');
}
}
Please suggest and where i am doing wrong.
Thanks
Hi Tara ch
You can checkout this link
https://salesforce.stackexchange.com/questions/11385/add-radio-button-to-custom-object
Thank You