I needed to put some colors in the rel tag of link using views. (eg. rel="ffdb6e,ffcc00") (this because they need to be handled by javascript later on).
I noticed the "text only" formatter also introduced html tags and a wrapper around #

So I created a quick patch with a raw hex formatter.
Might be usefull to someone so I decided to share it

@@ -307,7 +307,12 @@ function jquery_colorpicker_field_format
 			'label' => t('Text'),
 			'field types' => array('jquery_colorpicker'),
 		),
-	);
+    'jquery_colorpicker_raw_hex_display' => array
+    (
+      'label' => t('Raw hex'),
+      'field types' => array('jquery_colorpicker'),
+    ),
+  );
 }
 
 /**
@@ -315,24 +320,27 @@ function jquery_colorpicker_field_format
  */
 function jquery_colorpicker_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)
 {
-	$element = array();
-	foreach($items as $delta => $item)
-	{
-		if($display['type'] == 'jquery_colorpicker_color_display')
-		{
-			$element[$delta]['#markup'] = '<div id="jquery_colorpicker_color_display_' . $instance['id'] . '_' . $delta . '_' . $item['jquery_colorpicker'] . '">&nbsp;</div>';
-			$element[$delta]['#attached']['css'][] = array
-			(
-				'type' => 'inline',
-				'data' => '#jquery_colorpicker_color_display_' . $instance['id'] . '_' . $delta . '_' . $item['jquery_colorpicker'] . '{background-color:#' . $item['jquery_colorpicker'] . ';}',
-			);
-		}
-		elseif($display['type'] == 'jquery_colorpicker_text_display')
-		{
-			$element[$delta]['#markup'] = '<div class="jquery_colorpicker_text_display"><span class="jquery_colorpicker_hash_mark">#</span>' . $item['jquery_colorpicker'] . '</div>';
-		}
-	}
-	return $element;
+  $element = array();
+  foreach($items as $delta => $item)
+  {
+    switch ($display['type']) {
+      case 'jquery_colorpicker_color_display':
+        $element[$delta]['#markup'] = '<div id="jquery_colorpicker_color_display_' . $instance['id'] . '_' . $delta . '_' . $item['jquery_colorpicker'] . '">&nbsp;</div>';
+        $element[$delta]['#attached']['css'][] = array
+        (
+          'type' => 'inline',
+          'data' => '#jquery_colorpicker_color_display_' . $instance['id'] . '_' . $delta . '_' . $item['jquery_colorpicker'] . '{background-color:#' . $item['jquery_colorpicker'] . ';}',
+        );
+        break;
+      case 'jquery_colorpicker_text_display':
+        $element[$delta]['#markup'] = '<div class="jquery_colorpicker_text_display"><span class="jquery_colorpicker_hash_mark">#</span>' . $item['jquery_colorpicker'] . '</div>';
+        break;
+      case 'jquery_colorpicker_raw_hex_display':
+        $element[$delta]['#markup'] = $item['jquery_colorpicker'];
+        break;
+    }
+  }
+  return $element;
 }
 
 /**

Comments

rv0’s picture

hm something must have gone wrong when copypasting this patch..

the part where it starts is jquery_colorpicker_field_formatter_info()
sorry for that, needs some manual work.

This module isn't following drupal coding standards well btw..

plopesc’s picture

Status: Needs review » Fixed

Patch committed with attribution.

Thanks for your interest.

Status: Fixed » Closed (fixed)

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