Index: form_markup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/form_markup/form_markup.module,v
retrieving revision 1.5.2.3.2.4
diff -u -p -r1.5.2.3.2.4 form_markup.module
--- form_markup.module	11 Oct 2008 08:50:10 -0000	1.5.2.3.2.4
+++ form_markup.module	9 Apr 2010 16:33:39 -0000
@@ -14,9 +14,6 @@ function form_markup_form_alter(&$form, 
   if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
     form_markup_add_markup($form);
   }
-  else if ($form_id == 'content_field_edit_form') {
-    form_markup_admin_form($form);
-  }
 }
 
 /**  
@@ -34,58 +31,43 @@ function form_markup_add_markup(&$form) 
   }     
 }
 
-/** 
- * Additional form fields for the content_admin_field form to set prefix/suffix values
+/**
+ * Implementation of hook_widget_settings_alter().
  */
-function form_markup_admin_form(&$form) {
-  $form['widget']['form_markup'] = array(
-    '#type' => 'fieldset',
-    '#tree' => TRUE,
-    '#title' => t('Form Markup'),
-    '#collapsible' => TRUE,
-    '#description' => t('The values will surround your field on the content add/edit form. HTML is allowed'),
-  );
-  $form['widget']['form_markup']['prefix'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Prefix'),
-    '#rows' => 1,
-    '#cols' => 60,
-    '#default_value' => _form_markup_get_default_value($form['type_name']['#value'], $form['field_name']['#value'], 'prefix'),
-   );
-   $form['widget']['form_markup']['suffix'] = array(
-     '#type' => 'textarea',
-     '#title' => t('Suffix'),
-     '#rows' => 1,
-     '#cols' => 60,
-     '#default_value' => _form_markup_get_default_value($form['type_name']['#value'], $form['field_name']['#value'], 'suffix'),
-   );
-   $form['#submit'][] = 'form_markup_submit';
+function form_markup_widget_settings_alter(&$settings, $op, $widget) {
+  switch ($op) {
+    case 'form':
+      $settings['form_markup'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Form Markup'),
+        '#collapsible' => TRUE,
+        '#description' => t('The values will surround your field on the content add/edit form. HTML is allowed'),
+      );
+      $settings['form_markup']['prefix'] = array(
+        '#type' => 'textarea',
+        '#title' => t('Prefix'),
+        '#rows' => 1,
+        '#cols' => 60,
+        '#default_value' => isset($widget['prefix']) ? $widget['prefix'] : '' 
+      );
+      $settings['form_markup']['suffix'] = array(
+        '#type' => 'textarea',
+        '#title' => t('Suffix'),
+        '#rows' => 1,
+        '#cols' => 60,
+        '#default_value' => isset($widget['suffix']) ? $widget['suffix'] : ''
+      );
+      break;
+    case 'save':
+      $settings = array_merge($settings, form_markup_widget_settings());
+      break;
+  }
 }
 
-/** 
- * Additional submit handler on content_admin_field form
- *
- * writes prefix/suffix values to the widget settings and clears again the cache
+/**
+ * A list of settings needed by Form Markup module on widgets.
  */
-function form_markup_submit($form_id, &$form_state) {
-  $field = content_fields($form_state['values']['field_name'], $form_state['values']['type_name']);
-  $widget_settings = $field['widget'];
-  $widget_settings['prefix'] = $form_state['values']['form_markup']['prefix'];
-  $widget_settings['suffix'] = $form_state['values']['form_markup']['suffix'];
-
-  db_query("UPDATE {". content_instance_tablename() ."} SET widget_settings = '%s'
-    WHERE type_name = '%s' AND field_name = '%s'", serialize($widget_settings), $form_state['values']['type_name'], $form_state['values']['field_name']); 
-  content_clear_type_cache();
+function form_markup_widget_settings() {
+  return array('prefix', 'suffix');  
 }
 
-/** 
- * Helper function, that returns the values of the widget settings
- *
- * @param $type_name name of content_type
- * @param $field_name name of the field
- * @param $value name of the setting (prefix/suffix)
- */
-function _form_markup_get_default_value($type_name, $field_name, $value) {
-  $field = content_fields($field_name, $type_name);
-  return $field['widget'][$value];
-}
