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
JN22JN22 

VF Page Error - Could not resolve the entity from <apex:inputField> value binding

Hello,

 

I am new to VF pages and I'm getting an error but I don't know what it means.  My error when I try to save the VF page is:

 

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

 

Below is my VF page and Controller:

 

VF:

 

<apex:page standardController="Account" tabStyle="Account" extensions="TestController3">
   <apex:form >
   <apex:pageBlock >
       <apex:pageBlockSection columns="2">
            <apex:inputField value="{!test.Input_1__c}"/>
            <apex:inputField value="{!test.Input_2__c}"/>
       </apex:pageBlockSection>
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!Save}"/>
        </apex:pageBlockButtons>
       </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

Controller:

 

public class TestController3{

public List<Test_Object__c> test {get; set;}
    private final Account acct;
    public TestController3(ApexPages.StandardController myController) {
        acct=(Account)myController.getrecord();
        test= new List<Test_Object__c>();
        Test_Object__c test2 = new Test_Object__c();
        test2.Company_Name_Test__c = acct.id;
        test.add(test2);}


    public PageReference save() {
        insert test;
        PageReference home = new PageReference('/home/home.jsp');
        home.setRedirect(true);
        return home;

}

}

 

Can someone help?  Thanks,

 

John

 

  
aballardaballard

Looks like test is a list, not just an object.  You need to either return a single object from the controller, or change the page to iterate over the list.....

JN22JN22

Thanks for the input.  I'm not quite sure how to do either of those, but I will look around to see what I can find.

vriavmvriavm

Try this:

<apex:page standardController="Account" tabStyle="Account" extensions="TestController3">
   <apex:form >
   <apex:pageBlock >
        <apex:dataTable value="{!test}" var="data" id="theTable" rowClasses="odd,even" styleClass="tableClass">
        <apex:column>
            <apex:facet name="header">Input 1</apex:facet>
            <apex:inputField value="{!data.Input_1__c}"/>
        </apex:column>
        <apex:column>
            <apex:facet name="header">Input 2</apex:facet>
            <apex:inputField value="{!data.Input_2__c}"/>
        </apex:column>
    </apex:datatable>
    <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!Save}"/>
    </apex:pageBlockButtons>
       </apex:pageBlock>
    </apex:form>
</apex:page>

JN22JN22

Thanks.  Your page worked and I actually got it to work another way as well.  However, the problem I am having now is that the company name that is suposed to pre-populate from the Account is not doing so.  Any ideas on that?  Here's the updated VF page:

 

<apex:page standardController="Account" tabStyle="Account" extensions="TestController3">
   <apex:form >
    <apex:pageBlock title="Test" >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" rerender="error" />
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!test}" var="a" id="table">
                <apex:column headerValue="Company Name">
                    {!a.Company_Name_Test__c}
                </apex:column>                
                <apex:column headerValue="Input 1">
                    <apex:inputField value="{!a.Input_1__c}"/>
                </apex:column>                
                <apex:column headerValue="Input 2">
                    <apex:inputField value="{!a.Input_2__c}"/>
                </apex:column>
            </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>