--- button_field.module.old	2010-06-30 12:16:05.000000000 -0300
+++ button_field.module	2010-06-30 12:06:37.000000000 -0300
@@ -86,6 +86,10 @@
       'label' => 'Image Button',
       'field types' => array('button_field'),
     ),
+    'button_field_custom' => array(
+      'label' => 'Custom Button',
+      'field types' => array('button_field'),
+    ),
   ); // end return
 } // end function universitydegrees_widget_info()
 
@@ -175,6 +179,14 @@
         'title="'.$field['widget']['title_text'].'" '.
         'id="'.$name.'" name="'.$name.'" class="'.$class.'" />'."\n";
       break;
+      
+    case 'button_field_custom':
+      
+      $return_value = $field['widget']['prefix'].'<span id="'.$name.
+      	'" name="'.$name.'" '.'class="'.$class.'">'.$field['widget']['text'].
+      	'</span>'.$field['widget']['suffix']."\n";
+      
+      break; 
   } // end switch $field['widget']['type']
   
   return $return_value;
@@ -191,7 +203,7 @@
   // check to see if we are saving
   if ($op == 'save') {
     return array('text', 'image_path', 'title_text', 'alt_text',
-      'additional_class', 'edit_hidden');
+      'additional_class', 'edit_hidden', 'prefix', 'suffix');
   } // end if we are saving
   
   // determine which widget was selected
@@ -205,6 +217,11 @@
       
       return _button_field_widget_settings_image($op, $widget);
       break;
+      
+    case 'button_field_custom':
+      
+      return _button_field_widget_settings_custom($op, $widget);
+      break;
   } // end switch $widget['type']
 } // end function button_field_widget_settings()
 
@@ -332,6 +349,53 @@
 } // end function _button_field_widget_settings_image()
 
 /**
+ * Builds the array of setting for the custom button widget for button fields.
+ * 
+ * @param string $op
+ * @param array $widget
+ * @return array
+ */
+function _button_field_widget_settings_custom($op, $widget) {
+  // determine the current operation
+  switch ($op) {
+    case 'form':
+      
+      $form = array();
+      $form['text'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Button Text'),
+        '#default_value' => (isset($widget['text']) ? $widget['text']
+          : $widget['label']),
+        '#required' => TRUE,
+      ); // end $form['text']
+      
+      $form['prefix'] = array(
+      	'#type' => 'textfield',
+      	'#title' => t('Custom HTML Prefix'),
+      	'#default_value' => (isset($widget['prefix']) ? $widget['prefix']
+      	   : ""),
+      	'#required' => FALSE,
+	'#description' => t('The HTML code that goes <b>before</b> the custom button.'),
+      ); // end $form['prefix']
+ 
+      $form['suffix'] = array(
+      	'#type' => 'textfield',
+      	'#title' => t('Custom HTML Suffix'),
+      	'#default_value' => (isset($widget['suffix']) ? $widget['suffix']
+      	   : ""),
+      	'#required' => FALSE,
+	'#description' => t('The HTML code that goes <b>after</b> the custom button.'),
+      ); // end $form['suffix']
+      
+      $form = array_merge($form,
+        _button_field_widget_settings_common($op, $widget));
+      
+      return $form;
+      break;
+  } // end switch $op
+} // end function _button_field_widget_settings_custom()
+
+/**
  * Implementation of hook_widget().
  * 
  * Attach a single form element to the form.
@@ -389,6 +453,14 @@
         : _button_field_widget_image($form, $form_state, $field, $items,
           $delta));
       break;
+      
+    case 'button_field_custom':
+      
+      return ($field['widget']['edit_hidden']
+        ? array()
+        : _button_field_widget_custom($form, $form_state, $field, $items,
+          $delta));
+      break;
   } // end switch $field['widget']['type']
 } // end function button_field_widget()
 
@@ -505,6 +577,61 @@
 } // end function _button_field_widget_image()
 
 /**
+ * Implementation of hook_widget().
+ * 
+ * Attach a single form element to the form.
+ * 
+ * CCK core fields only add a stub element and builds
+ * the complete item in #process so reusable elements
+ * created by hook_elements can be plugged into any
+ * module that provides valid $field information.
+ * 
+ * Custom widgets that don't care about using hook_elements
+ * can be built out completely at this time.
+ * 
+ * If there are multiple values for this field and CCK is
+ * handling multiple values, the content module will call
+ * this function as many times as needed.
+ * 
+ * @param $form
+ *   the entire form array,
+ *   $form['#node'] holds node information
+ * @param $form_state
+ *   the form_state,
+ *   $form_state['values'][$field['field_name']]
+ *   holds the field's form values.
+ * @param $field
+ *   the field array
+ * @param $items
+ *   array of default values for this field
+ * @param $delta
+ *   the order of this item in the array of
+ *   subelements (0, 1, 2, etc)
+ * @return
+ *   the form item for a single element for this field
+ */
+function _button_field_widget_custom(&$form, &$form_state, $field, $items,
+  $delta) {
+  $name = $field['field_name'].'-'.(isset($form['nid']['#value'])
+    ? $form['nid']['#value'] : 0);
+  $class = 'button_field'.(isset($field['widget']['additional_class'])
+    ? ' '.$field['widget']['additional_class'] : '');
+  
+  $element['value'] = array(
+    '#type' => 'item',
+    '#value' => '<div id="'.$name.'" name="'.$name.
+    	'" class="'.$class.'">'.(isset($field['widget']['text'])
+      	? $field['widget']['text'] : $field['widget']['label']).'</div>'."\n",
+    '#prefix' => '<div class="form-item">'.$field['widget']['prefix'],
+    '#suffix' => $field['widget']['suffix'].'<div class="description">'.
+      (!empty($field['widget']['description']) ? $field['widget']['description']
+        : '').'</div></div>',
+  ); // end $element['value']
+  
+  return $element;
+} // end function _button_field_widget_custom()
+
+/**
 * Implementation of hook_theme().
 */
 function button_field_theme() {
@@ -526,4 +653,4 @@
  */
 function button_field_content_is_empty($item, $field) {
   return TRUE;
-} // end function button_field_content_is_empty()
\ No newline at end of file
+} // end function button_field_content_is_empty()
