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 -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 31 Dec 2008 16:54:16 -0000 @@ -2,7 +2,7 @@ // $Id: form_markup.module,v 1.5.2.3.2.4 2008/10/11 08:50:10 mh86 Exp $ /** - *@file + *@file * Adds prefix/suffix values for cck widgets */ @@ -19,22 +19,32 @@ } } -/** +/** * adds prefix/suffix values to the form (in form_alter) */ function form_markup_add_markup(&$form) { $fields = content_fields(NULL, $form['type']['#value']); if (is_array($fields)) { foreach ($fields as $field_name => $field) { - if (is_array($form[$field_name])) { - $form[$field_name]['#prefix'] = $field['widget']['prefix'] . $form[$field_name]['#prefix']; - $form[$field_name]['#suffix'] .= $field['widget']['suffix']; + if (isset($form[$field_name]) && is_array($form[$field_name])) { + if (strlen($field['widget']['prefix']) > 0) { + $form[$field_name]['#prefix'] = $field['widget']['prefix'] . $form[$field_name]['#prefix']; + } + + if (strlen($field['widget']['suffix']) > 0) { + if (isset($form[$field_name]['#suffix'])) { + $form[$field_name]['#suffix'] .= $field['widget']['suffix']; + } + else { + $form[$field_name]['#suffix'] = $field['widget']['suffix']; + } + } } - } - } + } + } } -/** +/** * Additional form fields for the content_admin_field form to set prefix/suffix values */ function form_markup_admin_form(&$form) { @@ -62,7 +72,7 @@ $form['#submit'][] = 'form_markup_submit'; } -/** +/** * Additional submit handler on content_admin_field form * * writes prefix/suffix values to the widget settings and clears again the cache @@ -74,11 +84,11 @@ $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']); + 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(); } -/** +/** * Helper function, that returns the values of the widget settings * * @param $type_name name of content_type