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.


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.

  • Sorry, using IsTest was a bad move on my part. The actual code uses something else. However, using inputCheckbox instead of inputField did fix it, thanks. – Ryan Elkins Aug 11 '12 at 13:13
  • Although you shouldn't do it since it already has meaning elsewhere, it doesn't matter that the variable is named isTest. It is a legal identifier name and wouldn't have any effect on the code not working. – Peter Knolle Aug 11 '12 at 13:46

isn't inputfield only available for sObject fields?

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


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

  • Sorry, I edited the question since the name was an unfortunate random name choice I made at ~ 1AM. It was actually inconsequential as the actual code I was using used a non reserved word. – Ryan Elkins Aug 11 '12 at 13:14

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}" .../>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.