Find your content:

Search form

You are here

Error: Could not resolve the entity from value binding '{!variable}'


This seems like it should be very simple and I have no idea why it isn't working.

I have a VF page with a controller. The controller has the following property (yes, I made sure to save):

public Boolean IsBool{ get; set; }

and the Visual Force page has the following code:

<apex:inputField value="{!IsBool}" label="Is a bool" />

This combination is giving me the following error when I try to save the Visual Force page:

Error: Could not resolve the entity from value binding '{!IsTest}'. can only be used with SObject fields.

I'm really unsure how to resolve this. I've made plenty of pages using this same pattern before. I'm guessing there is either something extremely obvious that I'm just not seeing or something really arcane.

AS further information, the property is being assigned to in the constructor. I've also tried assigning it in the get field but that didn't change anything.

Edit: Originally I had the property named IsTest (instead of IsBool) which is a reserved word but it was just a placeholder - the actual code uses something else and still gets the error. That was a bad move on my part to use that as the sample variable name for the purposes of the question.

Attribution to: Ryan Elkins

Possible Suggestion/Solution #1

IsTest is an annotation for classes, and as such would be a reserved word. Try renaming your variable in both instances to something else.

Attribution to: David Gillen

Possible Suggestion/Solution #2

IsTest is a reserved word in apex as it's used for test classes, and furthermore, <apex:inputField> only works with fields on SObjects, it can't be bound to regular public variables.

I think you're probably after something along the lines of:

<apex:inputCheckbox value="{!someBool}">a checkbox?</apex:inputCheckbox>

in your page, and

public boolean someBool {get; set;}

in your controller.

Attribution to: Matt Lacey

Possible Suggestion/Solution #3

isn't inputfield only available for sObject fields?

If you want to use a custom variable like "Isbool then you need "Inputtext" or "inputcheckbox"

Attribution to: Salesforce Wizard

Possible Suggestion/Solution #4

One way of handling this is to persist the boolean in a field of type checkbox. If adding this field to the object is not an option, then consider using InputCheckbox. If you want to logically tie this virtual field to a given record, though, e.g. when saving the record, then you should consider creating a wrapper class that contains a reference to the record and a public var of type Boolean, and exposing the class to the VF page, e.g. something along the line of

<apex:inputField value="{!wrapperClass.realObjectField__c}" .../>
<apex:inputCheckbox value="{!wrapperClass.virtualFieldBoolean}" .../>

Attribution to: datadriller
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content