I add colorpicker field as cck field and it is "NOT required field" this is where error came.

'' is not a valid hex color
The default value is invalid

Why should I set default if I don't required this field I think I should have a choice to leave it blank.
This also happen in node/add when I try to create node it asked me to fill the color, I use unlimited filed, so it end up I have to put at least two color to add a node (unlimited field has two default field).

Comments

hlykos’s picture

I have the same problem, it seems to work properly if you avoid multiple values.

skilip’s picture

I'll fix this this week

skilip’s picture

Component: User interface » Code
Assigned: Unassigned » skilip
eu.claudio’s picture

subscribing

thinkyhead’s picture

thank you! looking forward to the official 2.0 release party

skilip’s picture

This patch fixes the validation bug

jrust’s picture

Hmm, I applied the patch, and it does remove the validation error. However, now when I submit a node with an empty colorpicker value it automatically sets it to #FF0000.

skilip’s picture

Isn't that the default value specified in the Content Fields settings page? Did you try leaving that empty?

jrust’s picture

Yeah, the default value is blank for the content field settings field. Not sure where the FF0000 is coming from.

alan d.’s picture

In line 155 & 173 the default value is set if the existing value is not set.

So all existing items will default to NULL (empty string) and the new values to '#FF0000'. [If I'm reading the code correctly.]

Big +1 to not having any defaults in code! It is a pain to set the defaults on all colorpicker fields

The attached patch removes the default value along with the changes to the required / empty values as per the patch above

c960657’s picture

Status: Active » Needs review
StatusFileSize
new1.37 KB

AFAIK, CCK takes care of handling the required check.

The problem is that validation should only take place when a non-empty value has been entered. For the Colorpicker widget, the empty value is "#". colorpicker_cck_field() compares the submitted value to "#", but colorpicker_textfield_process() has already replaced the single "#" with "".

thinkyhead’s picture

Component: Code » User interface
Assigned: skilip » thinkyhead
Status: Needs review » Fixed
Issue tags: +cck fields

Applied the latest patch.

Status: Fixed » Closed (fixed)
Issue tags: -cck fields

Automatically closed -- issue fixed for 2 weeks with no activity.