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
Anil DuttAnil Dutt 

Auto populate input field

Hi,

i have a visualforce page and  want to auto pouplate a filed

<apex:page standardController="Itinerary__c" tabStyle="Itinerary__c" extensions="ItinerarySave">
    <apex:form >
        <apex:pageBlock title="Itinerary Edit" mode="edit">
            <apex:inputField label="Email To" value="{!email}" required="true"/>
         </apex:pageBlock>
    </apex:form>
</apex:page>


Apex class is

public class ItinerarySave {
    
    Itinerary__c it;
    public String email {get; set;}

    public ItinerarySave(ApexPages.StandardController stdController)
    {
        email = 'anil@swiftsetup.com';
    }

but it gives following error

Error: Could not resolve the entity from <apex:inputField> value binding '{!email}'. <apex:inputField> can only be used with SObject fields.

Please help

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Anil DuttAnil Dutt

Ok this is how it works

 

Need to bind the field to an object


so in apex class i need to do this

public class ItinerarySave {
    
    Itinerary__c it;
    public String email {get; set;}

    public ItinerarySave(ApexPages.StandardController stdController)
    {
        it.email__c = 'anil@swiftsetup.com';
    }