Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Problem with ColorPicker Module within Setting SiteConfig Tab


Go to End


1032 Views

Avatar
StefGuev

Community Member, 6 Posts

6 March 2015 at 6:20pm

Hi everyone, I'm very new to the world of programming under Silverstripe CMS and I love use it. I have installed this module
https://github.com/tractorcow/silverstripe-colorpicker/tree/master (ColorPicker). I have installed it into Page and Setting SiteConfig. When I using it with Page, there's no problem with the validation, but when I'm using it into Setting tab, the validation see to stall the CMS and I must reload my windows to silvertripeinstallation/admin because I cant click on other menu or retry submiting the form.

I maded a modification into the script to cancel bad color validation and return it blank and true. Is it a good idea?

I put a screenshot in attachment.

Thanks for your help!

------------
original code
------------
public function validate($validator) {
if(!empty ($this->value) && !preg_match('/^[A-f0-9]{6}$/', $this->value))
$validator->validationError($this->name, _t("ColourPicker.VALIDCOLOURFORMAT", "Please enter a valid color in hexadecimal format."), "validation", false);
return false;
}
return true;
}
-----------
code modified
-----------
public function validate($validator) {
if(!empty($this->value) && !preg_match("/^#?([a-f0-9]{3}$)|([a-f0-9]{6}$)/i", $this->value)) {
$this->value="";
return true;
}
return true;
}
-----------

Attached Files