PHP code example of tractorcow / silverstripe-colorpicker

1. Go to this page and download the library: Download tractorcow/silverstripe-colorpicker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tractorcow / silverstripe-colorpicker example snippets


private static $db = [
    'BgColor' => 'Color'
];

private static $db = [
    'BgColor' => Color::class
];

public function getCMSFields()
{
    $fields = parent::getCMSFields();

    $fields->addFieldToTab(
    	'Root.Main',
    	ColorField::create('BgColor', 'Background color')
    );

    return $fields;
}