You need to sign in to do that
Don't have an account?
Nitish Singh 22
Save data from VF form to Custom Object
I want to save values form a VF Page to a custom object Note__c. How do i go about it , please suggest.
This is how my Vf Page and corresponding controller class looks like
VF Page :
<apex:page id="notedetails" extensions="wk_NotesController" standardController="Note__c" showHeader="false" sidebar="false" standardStylesheets="false" docType="">
<apex:form id="inputform">
<apex:outputLabel styleClass="label" value="{!$ObjectType.Note__c.fields.Comments__c.Label}" />
<apex:inputField id="txtcmnt" value="{!val.Comments__c}" styleClass="box"/>
<apex:outputLabel styleClass="label" value="{!$ObjectType.Note__c.fields.Note_type__c.Label}" />
<apex:inputField id="drpdwn" value="{!val.Note_type__c}" styleClass="box"/>
<apex:commandButton action="{!saveValues}" value="Save" id="btnSave" />
</apex:form>
</apex:page>
Controller :
public with sharing class wk_NotesController {
public Note__c val{get;set;}
public String comments {
get;
set;
}
public String NoteType {
get;
set;
}
public wk_NotesController(ApexPages.StandardController cont){
val= (Note__c)cont.getRecord();
}
public PageReference saveValues(){
return null;
}
}
This is how my Vf Page and corresponding controller class looks like
VF Page :
<apex:page id="notedetails" extensions="wk_NotesController" standardController="Note__c" showHeader="false" sidebar="false" standardStylesheets="false" docType="">
<apex:form id="inputform">
<apex:outputLabel styleClass="label" value="{!$ObjectType.Note__c.fields.Comments__c.Label}" />
<apex:inputField id="txtcmnt" value="{!val.Comments__c}" styleClass="box"/>
<apex:outputLabel styleClass="label" value="{!$ObjectType.Note__c.fields.Note_type__c.Label}" />
<apex:inputField id="drpdwn" value="{!val.Note_type__c}" styleClass="box"/>
<apex:commandButton action="{!saveValues}" value="Save" id="btnSave" />
</apex:form>
</apex:page>
Controller :
public with sharing class wk_NotesController {
public Note__c val{get;set;}
public String comments {
get;
set;
}
public String NoteType {
get;
set;
}
public wk_NotesController(ApexPages.StandardController cont){
val= (Note__c)cont.getRecord();
}
public PageReference saveValues(){
return null;
}
}
add extensions in page code of extensions class will be like this.
Please mark the Question solved it it resolve the issue by selecting it best answer.