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
Ranadheer chRanadheer ch 

How to save my <apex:inputfield> with my custom save method which is in controller

Here inthis page using the {!SaveDueFrom} i can insert the input text values into object..but i also want to insert the inputfiled values also with the same action what to do? How to pass that to that SaveDueFrom method in controller.

My vf page:
<apex:page standardController="File_New_Protest__c" Extensions="Filenewexten">
<apex:form>
<apex:pageBlock >
<apex:pageBlockSection title="Protester " columns="3">
<apex:inputText value="{!CompanyName}" />
<apex:inputText value="{!StreetName}" id="cstreet"/>
<apex:inputField value="{!File_New_Protest__c.Agency_Tier1__c}"/>
<apex:inputField value="{!File_New_Protest__c.Comments__c}"/> 
<apex:commandButton value="Save" action="{!SaveDueFrom}"/>
</apex:pageBlockSection>
</apex:pageBlock >
<apex:form>
<<apex:page>

My controller:

public with sharing class Filenewexten {
public Filenewexten(ApexPages.StandardController controller) {
}
 public string  CompanyName{get;set;}
      public string  StreetName{get;set;}

public Void SaveDueFrom(){
File_New_Protest__c Insertfile=New File_New_Protest__c();
 Insertfile.Company_Name__c=CompanyName;
Insertfile.Street_Name__c=StreetName;
insert(Insertfile);
}


please help me inthis ...thanks in advance
Sumitkumar_ShingaviSumitkumar_Shingavi
You code should be:

Visualforce:
<apex:page controller="FilenewCC">
	<apex:form>
		<apex:pageBlock >
			<apex:pageBlockSection title="Protester " columns="3">				
				<apex:inputField value="{!insertFile.Agency_Tier1__c}"/>
				<apex:inputField value="{!insertFile.Comments__c}"/> 
				<apex:commandButton value="Save" action="{!SaveDueFrom}"/>
			</apex:pageBlockSection>
		</apex:pageBlock >
	<apex:form>
<apex:page>

Apex Classes:
public with sharing class FilenewCC {

	public File_New_Protest__c insertFile {get; set;}

	public Filenewexten(ApexPages.StandardController controller) {
		insertFile = File_New_Protest__c();
	}
	
	public Void SaveDueFrom() {
		insert insertFile;
		insertFile = new File_New_Protest__c();
	}
}

Hope this helps!

PS: if this solves your problem then mark it as solution.
Roy LuoRoy Luo
<apex:page standardController="File_New_Protest__c" Extensions="Filenewexten">
<apex:form>
<apex:pageBlock >
<apex:pageBlockSection title="Protester " columns="3">
<apex:inputText value="{!ObjEntity.Company_Name__c}" />
<apex:inputText value="{!ObjEntity.Street_Name__c}" id="cstreet"/>
<apex:inputField value="{!ObjEntity.Agency_Tier1__c}"/>
<apex:inputField value="{!ObjEntity.Comments__c}"/> 
<apex:commandButton value="Save" action="{!SaveDueFrom}"/>
</apex:pageBlockSection>
</apex:pageBlock >
<apex:form>
<<apex:page>
Controller:
public with sharing class Filenewexten 
{
	public Filenewexten(ApexPages.StandardController controller) 
	{
		 SObject obj = controller.getRecord();

		 if(obj!=null)
		 {
		 	 ObjEntity = (File_New_Protest__c)obj;
		 }
		 else
		 {
		 	 ObjEntity = new File_New_Protest__c();
		 }
	}
	
	public File_New_Protest__c  ObjEntity {get;set;}

	public Void SaveDueFrom()
	{
		upsert ObjEntity;
	}
}