? field_example.patch
Index: field_example.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/examples/field_example/field_example.module,v
retrieving revision 1.7
diff -u -p -r1.7 field_example.module
--- field_example.module	28 Jun 2010 20:02:50 -0000	1.7
+++ field_example.module	24 Aug 2010 07:23:19 -0000
@@ -80,9 +80,9 @@ function field_example_field_schema($fie
  * (6 hex digits with a # at the beginning).
  */
 function field_example_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
-  foreach($items as $delta => $item) {
-    if(!empty($item['rgb'])) {
-      if(! preg_match('@^#[0-9a-f]{6}$@', $item['rgb'])) {
+  foreach ($items as $delta => $item) {
+    if (!empty($item['rgb'])) {
+      if (! preg_match('@^#[0-9a-f]{6}$@', $item['rgb'])) {
         $errors[$field['field_name']][$langcode][$delta][] = array(
           'error' => 'field_example_invalid',
           'message' => t('Color must be in the HTML format #abcdef.'),
@@ -141,8 +141,7 @@ function field_example_field_formatter_v
     // This formatter simply outputs the field as text and with a color.
     case 'field_example_simple_text':
       foreach ($items as $delta => $item) {
-        $element[$delta]['#markup'] = '<p style="color: ' . $item['rgb']. '">'
-          . t('The color code in this field is @code', array('@code' => $item['rgb'])) . '</p>';
+        $element[$delta]['#markup'] = '<p style="color: ' . $item['rgb'] . '">' . t('The color code in this field is @code', array('@code' => $item['rgb'])) . '</p>';
       }
       break;
 
@@ -150,9 +149,8 @@ function field_example_field_formatter_v
     // background color. If there are many fields, the last one will win.
     case 'field_example_color_background':
       foreach ($items as $delta => $item) {
-        drupal_add_css('div.region-content { background-color:' . $item['rgb'] .';}', array('type' => 'inline') );
-        $element[$delta]['#markup'] = '<p>'
-          . t('The content area color has been changed to @code', array('@code' => $item['rgb'])) . '</p>';
+        drupal_add_css('div.region-content { background-color:' . $item['rgb'] . ';}', array('type' => 'inline') );
+        $element[$delta]['#markup'] = '<p>' . t('The content area color has been changed to @code', array('@code' => $item['rgb'])) . '</p>';
       }
       break;
   }
@@ -315,7 +313,7 @@ function field_example_3text_validate($e
 }
 
 /**
- * Implements hook_field_error().
+ * Implements hook_field_widget_error().
  */
 function field_example_field_widget_error($element, $error, $form, &$form_state) {
   switch ($error['error']) {
