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
Pat WimsattPat Wimsatt 

apex:inputField

Any idea why this is throwing an error:  Error: Could not resolve the entity from <apex:inputField> value binding '{!lanes.origin_city__c}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.


my vfp file...
<apex:form >   
        <apex:pageBlock title="OD List" id="od_list" mode="edit">
        
        
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!lanes.origin_city__c}"/>
                <apex:inputField value="{!lanes.origin_statess__c }"/>
                <apex:inputField value="{!lanes.Destination_City__c }"/>
                <apex:inputField value="{!lanes.Destination_States__c}"/>
            </apex:pageBlockSection>       
        

Here's my controller:
public class LaneDetailCon {
 
    static List<Lane_Detail__c> lanes;
 
    public static List<Lane_Detail__c> getLanes() {
        
            String City  = ApexPages.currentPage().getParameters().get('origin_city__c');
        
            lanes = [SELECT Origin_City__c, Origin_Statess__c, Destination_City__c,
                     Destination_States__c, Rate__c FROM Lane_Detail__c 
                     WHERE Origin_City__c = :City 
                     LIMIT 25];
        return lanes;
    }
 }
Best Answer chosen by Pat Wimsatt
RituSharmaRituSharma
lanes is a list type of variable and may have many records. If you want to show all of them, use <apex:repeat> to show one by one. If you want to show just the first one then instead of referring as lanes, use lanes[0]. So you will need to access like below:

<apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!lanes[0].origin_city__c}"/>
                <apex:inputField value="{!lanes[0].origin_statess__c }"/>
                <apex:inputField value="{!lanes[0].Destination_City__c }"/>
                <apex:inputField value="{!lanes[0[.Destination_States__c}"/>
            </apex:pageBlockSection>

Refer the URL to see how <apex:repeat> can be used -> https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_repeat.htm

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi Pat,

Greetings!

I would request you to double check the API name of the field to refer on the <apex:inputField> tag since it should be from the SObject referred.

Reference:https://salesforce.stackexchange.com/questions/34401/apexinputfield-can-only-be-used-with-sobjects

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Pat WimsattPat Wimsatt
Thanks Shirisha, but I've verified that, and read the article you suggest even before I posted here.   <apex:inputField value="{!lanes.origin_city__c}"/> for example.  !lanes is my sObject and origin_city__c is my field name.  If I put this in a datatable block using column it renders perfectly.  There's something more too it I'm missing.  Any other thoughts?  
RituSharmaRituSharma
lanes is a list type of variable and may have many records. If you want to show all of them, use <apex:repeat> to show one by one. If you want to show just the first one then instead of referring as lanes, use lanes[0]. So you will need to access like below:

<apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!lanes[0].origin_city__c}"/>
                <apex:inputField value="{!lanes[0].origin_statess__c }"/>
                <apex:inputField value="{!lanes[0].Destination_City__c }"/>
                <apex:inputField value="{!lanes[0[.Destination_States__c}"/>
            </apex:pageBlockSection>

Refer the URL to see how <apex:repeat> can be used -> https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_repeat.htm
This was selected as the best answer
Pat WimsattPat Wimsatt
Thanks RituSharma.  Yes, I want ALL the records that are returned in the list to be displayed on the new form. Not one by one, but on in a list form.  I do not need an input field however as the records will not be edited, they simply need to be displayed.  I will experiment with apex:repeat but if you could provide an example of that, it would be greatly appreciated. 
 
RituSharmaRituSharma
Your may refer below code:

<apex:repeat value="{!lanes}" var="lane"> 
         <apex:outputtext value="{!lane.origin_city__c}"/>
         <apex:outputtext value="{!lane.origin_statess__c }"/>
         <apex:outputtext value="{!lane.Destination_City__c }"/>
         <apex:outputtext value="{!lane.Destination_States__c}"/> 
</apex:repeat>

Please mark this as the best answer if it serves the purpose. This will be helpful for others in future.