PHP code example of fromholdio / silverstripe-colorpalette

1. Go to this page and download the library: Download fromholdio/silverstripe-colorpalette 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/ */

    

fromholdio / silverstripe-colorpalette example snippets


$fields->addFieldToTab(
    'Root.Main',
    Fromholdio\ColorPalette\Fields\ColorPaletteField::create(
        'BackgroundColor',
        'Background Color',
        [
            // still works
            'white' => '#fff',      // will be applied as 'background_css' value
            // new config options
            'black' => [
                'label' => 'Jet Black',     // displayed in field under color box
                'background_css' => '#111', // without ';', used to fill in color box
                'color_css' => '#FFFFFE',   // used to style the sample_text displayed on top of color box
                'sample_text' => 'Aa'       // if color_css is provided, this text displayed on top of color box
            ]
        ]
    )
);

$fields->addFieldToTab(
    'Root.Main',
    Fromholdio\ColorPalette\Fields\GroupedColorPaletteField::create(
        'BackgroundColor',
        'Background Color',
        [
            'Group title' => [
                'black' => '#000',
                'white' => [
                    'label' => 'White',
                    'background_css' => '#FFF',
                    'color_css' => '#000',
                    'sample_text' => 'Aa'
                ]
            ],
            'Another group title' => [
                'red' => '#ff0'
            ]
        ]
    )
);