I tried to pass the input field variable value(as provided by the user) to a global variable in the controller. I have the following code.

<div class="Modal">
    <apex:pageBlockSectionItem id="DateTimeofComment">
        <apex:outputLabel>Comment Sent Date</apex:outputLabel>
        <apex:inputfield id="CommentDate" value="{!AModel.dateTimeInput}" />
        <apex:commandButton action="{!AModel.save}" value="Save" id="saveCommentButton" />

AModel is an extension class. In the AModel class I have the global variable

public DateTime dateTimeInput {get;set;}
public void save() {
    //Save Code.............

What is happening is that whenever I am trying to save the visualforce page code given above it is throwing the following error.


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

Can anyone tell me how this issue will be ressolved?


2 Answers 2


A good solution to this is to use a proxy object in the controller to capture the dateTime value

public Event evt { // proxy object, fld StartDateTime is creatable
  get {
    if (this.evt == null)
         this.evt = new Event();
    return this.evt; 

... elsewhere in your controller (like in the custom save action method, you can use this.evt.startDateTime to reference the user-entered datetime.

Then your VF page is:

    <apex:pageBlockSectionItem id="DateTimeofComment">
        <apex:outputLabel>Comment Sent Date</apex:outputLabel>
        <apex:inputfield id="CommentDate" value="{!evt.startDateTime}" />
        <apex:commandButton action="{!save}" value="Save" id="saveCommentButton" />

The advantage of this approach is you leverage the builtin SFDC datetime picker and you can avoid all the hassle of parsing datetimes.

  • Now that is something amazing.
    – Mr.Frodo
    Commented Jun 8, 2016 at 6:01

The error which you are getting describe this:

If it's not an sObject field, you have to use one of the typed input tags. In your case, you would use <apex:inputText>.

Additional options include <apex:inputcheckbox> and <apex:inputTextArea> to handle other data types.

  • I am appending the date picker to it. If I use <apex:inputText> it would not be a input date field. Is there any other way? @Mr.Frodo
    – Rimii
    Commented Jun 8, 2016 at 5:26
  • There are several ways to achieve this, check this: Datepicker in Visualforce page
    – Mr.Frodo
    Commented Jun 8, 2016 at 5:47
  • One more nice post on this.
    – Mr.Frodo
    Commented Jun 8, 2016 at 5:55

You must log in to answer this question.

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