While leveraging the Style (CSS) settings module to have #2420905: Configurable CSS for the Flickr module (see step nr. 3 of the instructions), I had a hard time to add a ColorPicker field to the settings form.
Fact is that a lot of CSS attributes contain a color value. Although also a simple text field could hold a color hex value, it would enhance UX a lot if also a colorpicker is offered and the choosen color would be visible. Apart from validating the user input as being a valid color.
Some contrib module does offer an API to have a 'color' field but this implies:
- having a dependency
- not only on the module itself but also a jQuery library
- overkill as the contrib module also adds functionality we don't use.
Drupal core does already have the Farbtastic plugin used by the core Color module located at '/misc/farbtastic/farbtastic.js'. It is hard to make use of it as the Drupal form API does not offer a 'color' form element type.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | field_wrapper_to_target_right_with_js-2528252-5.patch | 695 bytes | lolandese |
| #1 | colorpicker_field_api-2528252-1.patch | 7.19 KB | lolandese |
Comments
Comment #1
lolandese commentedAttached patch:
For project maintainers adding a color setting to their configuration is as easy as:
to get:

Comment #3
lolandese commentedComment #4
lolandese commentedBuggy with multiple color fields. Clicking not the first instance opens the color picker under the first.
Comment #5
lolandese commentedComment #7
lolandese commented