+ Start a Discussion
user23232323user23232323 

apex:inputField lookup field issue

Hi,

Im running into an issue with the apex:inputfield when trying to save my Visualforce page.

Error: Could not resolve the entity from <apex:inputField> value binding '{!userManagerRec}'.  <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.

It says it requires an SObject yet that's what I perceive I am passing it. Any assistance is appreciated. Thanks ahead of time!
 
<apex:page controller="UserController" showHeader="true" sidebar="true" >
<apex:form>
		<td><apex:inputField style="width:97%; line-height:1.875em;" value="{!userManagerRec}"/>
</apex:form>
</apex:page>

public without sharing class UserController {

	public String userManagerId {get;set;}

	public UserController(){

    	userManagerId = ApexPages.currentPage().getParameters().get('uid');

    	if(userManagerId != null && userManagerId != ''){
    		
    		loadUserManagerRecord();

    	}

    }
	
	public User userManagerRec {
    	get{
    		if(userManagerRec == null) userManagerRec = new User();
    		return userManagerRec;
    	}
    	set;
    }
	
	public User loadUserManagerRecord(){

    	for(User u : [select Id, Name from User where Id =: userManagerId LIMIT 1]){
    		userManagerRec = u;
    	}
    	return userManagerRec;

    }

}



 
@anilbathula@@anilbathula@
Hi user23232323,

Try this vf page and class
 
public without sharing class UserController {

    public String userManagerId {get;set;}
    Public user usr{get;set;}

    public UserController(){
        userManagerId = ApexPages.currentPage().getParameters().get('uid');
        User u = [select Id, firstName from User where Id =: userManagerId LIMIT 1];
    }
    
}
 
<apex:page controller="UserController" showHeader="true" sidebar="true" >
    <apex:form>
        <apex:pageBlock>
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!usr.firstname}"/>
                <apex:inputField value="{!usr.Lastname}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Thanks
Anil.B​​​​​​​