0
    <apex:page Controller="PaypalProccessor" >
  <!-- Page Header -->
  <apex:sectionHeader title="Pay With PayPal" subtitle="Safe hai" />
  <!-- Begin Form -->
  <apex:form >
    <apex:pageBlock title="Enter Details" mode="edit" >
      <!-- Fields -->
      <apex:pageBlockSection columns="3" showHeader="true" title="Membership Status" >
        <apex:inputField value="{!firstName}" required="true" />
        <apex:inputField value="{!lastName}" required="true" />
        <apex:inputField value="{!Addy1}"  required="true" />
        <apex:inputField value="{!Addy2}" />
        <apex:inputField value="{!CardNo}" required="true" />
        <apex:inputField value="{!expMo}" required="true" />
        <apex:inputField value="{!expYe}" required="true" />
      </apex:pageBlockSection>
      <!-- Button Section -->
      <apex:pageBlockButtons location="bottom">
        <apex:commandButton value="Submit" action="{!doDirectPayment}" />
      </apex:pageBlockButtons>
    </apex:pageBlock>
  </apex:form>
</apex:page>

What I am doing wrong? It is giving me this error Could not resolve the entity from value binding '{!firstName}'. can only be used with SObjects, or objects that are Visualforce field component resolvable.

2 Answers 2

0

<apex:inputField can be used on field references only. For example <apex:inputField value="{!contact.FirstName}" or <apex:inputField value="{!objectInstance.FirstName}". If you are just referring some variable defined in your controller, use <apex:inputtext value="{!firstName}"

1
  • I have tried with the <apex:inputText> and it is working fine, but I wanted to use it with <apex:inputField> Well thanks for your reply
    – H John
    Apr 3, 2020 at 7:00
0

If you want to be able to use apex:inputField and apex:outputField in your page, you need your controller to expose an SObject into which you can store those values, as stated in sfwizard's answer.

You don't have to switch to using apex:inputText if you simply add appropriate SObjects in your controller, like:

class MyController {
    public Contact contactData { get; set; }

    public MyController(ApexPages.StandarController standardController) {
        contactData = new Contact(FirstName = 'Default');
    }
}

Now you can access this in your VF page using:

<apex:pageBlock title="Enter Details" mode="edit">
  <!-- Fields -->
  <apex:pageBlockSection columns="3" showHeader="true" title="Membership Status">
    <apex:inputField value="{!contactData.FirstName}" required="true"/>

You will then find that the contactData.FirstName is available in your submit button handler in the controller.

You can use as many different SObjects as you like for this pattern, cherry picking the field values out of them during submission processing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .