Project:Colorpicker
Version:6.x-2.0-rc3
Component:User interface
Category:bug report
Priority:normal
Assigned:thinkyhead
Status:closed (fixed)
Issue tags:cck fields

Issue Summary

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

#1

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

#2

I'll fix this this week

#3

Component:User interface» Code
Assigned to:Anonymous» skilip

#4

subscribing

#5

thank you! looking forward to the official 2.0 release party

#6

This patch fixes the validation bug

AttachmentSize
colorpicker_invalid_hex_color.491934.1.patch 1.11 KB

#7

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.

#8

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

#9

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

#10

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

AttachmentSize
colorpicker_invalid_hex_color.491934-10.patch 1.8 KB

#11

Status:active» needs review

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

AttachmentSize
colorpicker-required-1.patch 1.37 KB

#12

Component:Code» User interface
Assigned to:skilip» thinkyhead
Status:needs review» fixed

Applied the latest patch.

#13

Status:fixed» closed (fixed)

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