Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I'm trying to develop a color picker using JSColor but I don't know how to do it with an <apex:inputField>. I have the error below :

Save error: Could not resolve the entity from value binding '{!color}'. can only be used with SObjects, or objects that are Visualforce field component resolvable.

Here's my code :

VF :

<apex:inputField styleClass="color" value="{!color}" />

Controller :

public SObject color {get; set;}

I can't use another object type like String. But it doesn't work with SObject.

Do I need to use a standard object like Account or a custom object saved in database ? I don't want to create a custom object only for store the color. If possible I just want to store it in a controller field.

share|improve this question
3  
Try to use apex:inputText instead. –  mast0r Aug 26 at 12:18
    
So obvious, I didn't think about that. Thanks mast0r, it works but now I have a problem with the JSColor library. I can't see the color I'm choosing... –  SF_user Aug 26 at 12:28

1 Answer 1

up vote 2 down vote accepted

SObject is a complex type. Therefore you cannot assign a simple value like a color code (string).

In your case it makes sense to add a custom field to your sObject (e.g. Color__c). This field can be referenced by anAccount.Color__c.

Example

public Account anAccount {get; set;}

And

<apex:inputField styleClass="color" value="{!anAccount.Color__c}" />
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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