Closed odonnetp closed 11 years ago
Hi @odonnetp , I've tested your code in both SS 3.1 and 3.0 and they both seem fine. Do you think you could please help me reproduce your issue?
What is your exact SS version? Can you provide a full working example I can use? (DataObject or Page) Have you noticed any JS errors? Are the colorfield.js and colorpicker.js files being included?
I don't think the JS files are being called, but not sure why...is there anything within a config file or anything that I have to call in the JS files? Again, I'm trying to add to Nivo Slider (https://github.com/micmania1/silverstripe-nivoslider). I'm using SS 3.0. I have Nivo Slider folder in root and also color picker in root. Nivo Slider is done within its own Admin area (not within a page), could that have any reason why it isn't working?
Here is the code I have for NivoSliderSlide.php. I was testing just with the Text color to make it a color picker (previously I had admin just add it as rgb code):
<?php
/**
@subpackage nivoslider
**/
class NivoSliderSlide extends DataObject {
public static $db = array(
"Title" => "Varchar(255)",
"BackgroundColor" => "Text",
"TextColor" => "Text",
"Caption" => "Varchar(255)",
"Link" => "Text",
"LinkTitle" => "Text",
);
public static $has_one = array( "NivoSlider" => "NivoSlider", "SlideImage" => "Image", );
public static $summary_fields = array( "SlideImage.CMSThumbnail" => "Slide Image", "Title" => "Title", );
public static $searchable_fields = array( "Title", "Caption", "SlideImage", );
public function getCMSFields() { $fields = parent::getCMSFields();
// Remove unneccesary fields.
$fields->removeByName("NivoSliderID");
$fields->push(TextField::create("Title", "Title"));
$fields->push(TextField::create("BackgroundColor", "Background Color (optional, must be like rgba (255, 0, 0, 0.2))"));
$fields->push(ColorField::create("TextColor", "Text Color (optional, must be in rgb or color code format)"));
$fields->push(TextField::create("LinkTitle", "Link Title"));
$fields->push(TreeDropdownField::create("Link", "Link", "Page", "URLSegment", "MenuTitle"));
$fields->push(TextField::create("Caption", "Caption"));
$fields->insertBefore($slideImage = UploadField::create("SlideImage", "Slide Image"), "Caption");
$slideImage->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
$slideImage->setConfig('allowedMaxFileNumber', 1);
return $fields;
} }
Hiya, I'm working my way through this.
Why is SlideImage a searchable field? It crashes my test code.
Figured it out. Needed to change the folder to be "colorpicker" as that is the folder structure it is calling in code/forms/ColorField.php.
:P aha, solution!
How about I fix the install documentation... it's a little outdated.
Thanks for your help. By the way, use composer! It'll solve all these issues for you in the future. :P
I've updated the docs - See https://github.com/tractorcow/silverstripe-colorpicker#installation
Appreciate it! Looking good, thanks again. Haven't used composer but will look into it.
Hi there,
I wanted to add this to a site, specifically to a Nivo Slider module. The code for Nivo Slider is as such:
public function getCMSFields() { $fields = parent::getCMSFields();
}
I tried to copy suit and add the following:
but after I save, run dev/build, and go to backend, when I click on the field for text color, nothing happens. Any thoughts to why this might not be working?