This is a personal modification I made, I needed just the hex value (#FFFFFF) to use in a view, whithout any text, I use that to change the background color of a div appearing in a calendar event. This way user can choose the color for their event, I'm not able to create a patch file, but I leave this here for reference, I would like to see something like this in the final release.

I just added a few lines:

1. in field_color_field_formatter_info function:

function field_color_field_formatter_info() { ...
...
'field types' => array('field_color_rgb'),
    ),

+ // This formatter just display the hex
+    'field_color_as_hex' => array(
+      'label' => t('Show the hex code of the color'),
+      'field types' => array('field_color_rgb'), 
+   ),

2. in field_color_field_formatter_view function

function field_color_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();....
...
 $element[$delta]['#markup'] = '<p>' . t('The content area color has been changed to @code', array('@code' => $item['rgb'])) . '</p>';
      }
      break;

+     case 'field_color_as_hex':
+      foreach ($items as $delta => $item) {
+        $element[$delta]['#markup'] = $item['rgb'];
+      }
+      break;

Comments

Artusamak’s picture

Status: Active » Fixed

Indeed, this formatter make sense!
It's now integrated: http://drupalcode.org/project/colorfield.git/commitdiff/3bfbba91bd9b5472...

Thanks for the suggestion.

Tips for your next contribution, post a patch in the issue, it will ease the maintainer's life to integrate your feature. ;)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.