it-blaster/color-picker-type-bundle

The FormType for choosing a color

v1.0.3 2015-07-13 08:08 UTC

This package is not auto-updated.

Last update: 2024-11-09 17:40:32 UTC


README

Scrutinizer Code Quality Build Status License Total Downloads Latest Unstable Version Latest Stable Version

The FormType for choosing a color based on Iris.

Installation

Add it-blaster/color-picker-type-bundle to your composer.json file and run composer

...
"require": {
    "it-blaster/color-picker-type-bundle": "1.0.*"
}
...

Register the bundle in your AppKernel.php

...
new Fenrizbes\ColorPickerTypeBundle\FenrizbesColorPickerTypeBundle(),
...

Include bundle's scripts and Iris' dependencies in your page:

...
<script src="path/to/jquery.js"></script>
<script src="path/to/jquery-ui.js"></script>
<script src="{{ asset('bundles/fenrizbescolorpickertype/lib/js/iris.min.js') }}"></script>
<script src="{{ asset('bundles/fenrizbescolorpickertype/js/color_picker_type.js') }}"></script>
...

Usage

Just set the color_picker FormType for your field as follows:

...
    ->add('color', 'color_picker')
...

Options

You can pass all the Iris' options as a picker_options value:

...
    ->add('color', 'color_picker', array(
        'picker_options' => array(
            'color'    => false,
            'mode'     => 'hsl',
            'hide'     => true,
            'border'   => true,
            'target'   => false,
            'width'    => 200,
            'palettes' => false,
            'controls' => array(
                'horiz' => 's',
                'vert'  => 'l',
                'strip' => 'h'
            )
        )
    ))
...