0

I have been struggling to get default color picker work. When I add a new color field ( new \Ip\Form\Field\Color) on form page then after selecting color from drop down I get error "incorrect color code". And when I checked value returned is something like this "hsv(0, 25%, 34%)".

After checking in Core files, Color Form field file then I found following function which is validating it.

public function validate($values, $valueKey, $environment)
{
    if (preg_match('/^#([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$\b/', $values[$valueKey])) {
        return parent::validate($values, $valueKey, $environment);
    } else {
        if ($environment == \Ip\Form::ENVIRONMENT_ADMIN) {
            return __('Incorrect color code', 'Ip-admin', false);
        } else {
            return __('Incorrect color code', 'Ip', false);
        }
    }
}

Can you please check and let me know why it is generating HSV code for color "hsv(0, 25%, 34%)"

Thanks in advance.

4

2 回答 2

0

The problem is in current value of that field. If JavaScript can't understand the value, it falls back to HSV. Set the default (or current) value to RGB. Eg. #ffffff. That will solve the problem for now. I will try to do something to fix this in general.

于 2014-09-11T07:18:20.780 回答