3

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.

2
  • 3
    Try to use apex:inputText instead. Aug 26, 2014 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, 2014 at 12:28

1 Answer 1

2

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

You must log in to answer this question.

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