it-blaster / color-picker-type-bundle
选择颜色的 FormType
v1.0.3
2015-07-13 08:08 UTC
Requires
- php: >=5.3.2
- symfony/framework-bundle: ~2.1
This package is not auto-updated.
Last update: 2024-09-14 16:50:19 UTC
README
基于 Iris 的选择颜色的 FormType。
安装
将 it-blaster/color-picker-type-bundle 添加到您的 composer.json
文件中,并运行 composer
... "require": { "it-blaster/color-picker-type-bundle": "1.0.*" } ...
在您的 AppKernel.php
中注册该包
... new Fenrizbes\ColorPickerTypeBundle\FenrizbesColorPickerTypeBundle(), ...
在您的页面中包含包的脚本和 Iris 的依赖
... <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> ...
用法
只需将您的字段的 color_picker
FormType 设置如下
... ->add('color', 'color_picker') ...
选项
您可以将 Iris 的所有选项作为 picker_options
值传递
... ->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' ) ) )) ...