Drupal has its own color picker system. Drupal’s Farbtastic is very easy to add a color picker with your drupal form.
here is the code for your form item.
drupal_add_css('misc/farbtastic/farbtastic.css'); drupal_add_js('misc/farbtastic/farbtastic.js'); $form ['site_pagetitlecolor'] = array( '#type' => 'textfield', '#title' => t('Page Title Color'), '#default_value' => '#FFF', '#description' => '<div id="site_pagetitlecolor_colorpicker"></div>', '#size' => 9, '#maxlength' => 7, '#suffix' => "<script type='text/javascript'> $(document).ready(function() { $('#site_pagetitlecolor_colorpicker').farbtastic('#edit-site-pagetitlecolor'); }); </script>" );?
Adding this will provide your form item with a color picker. :)
woh I love your posts , saved to favorites ! .
D7 example?? tks
never mind! its working great in D7
:P
just chance the $ jquery selector with jQuery
Does this still work? I can’t get it going for anything.
Still works in Drupal 7.39. As Mayk Brito’s comment says, change $(document) and $(‘#site_pagetitlecolor_colorpicker’) with jQuery(document) and jQuery(‘#site_pagetitlecolor_colorpicker’).
Awesome post. Thanks!