--- /Users/jeff/Desktop/tmp/textfield_autocomplete/5.x-1.x-dev/textfield_autocomplete.module 2007-08-31 09:18:43.000000000 -0700 +++ textfield_autocomplete.module 2007-10-16 13:32:09.000000000 -0700 @@ -5,6 +5,7 @@ // $Id: textfield_autocomplete.module,v 1.1 2007/08/31 16:18:43 linuxbox Exp $ + /** * Implementation of hook_menu. */ @@ -22,6 +23,7 @@ function textfield_autocomplete_menu($ma return $items; } // function nonsense_menu + /** * Implementation of hook_widget_info(). */ @@ -34,6 +36,28 @@ function textfield_autocomplete_widget_i ); } + +/** + * Implementation of hook_widget_settings() + */ +function textfield_autocomplete_widget_settings($op, $widget) { + switch ($op) { + case 'form': + $form = array(); + $form['autocomplete_path'] = array( + '#type' => 'textfield', + '#title' => t('Autocomplete Path'), + '#default_value' => isset($widget['autocomplete_path']) ? $widget['autocomplete_path'] : '', + '#description' => t('This value will be used as the path the autocomplete widget. If it is left blank, all distinct values entered for this field will be used as the autocomplete return values.'), + ); + return $form; + + case 'save': + return array('autocomplete_path'); + } +} + + /** * Implementation of hook_widget(). */ @@ -43,6 +67,7 @@ function textfield_autocomplete_widget($ $form = array(); $form[$field['field_name']] = array('#tree' => TRUE); + $autocomplete_path = $field['widget']['autocomplete_path'] ? $field['widget']['autocomplete_path'] : 'textfield_autocomplete/'.$field['field_name']; if ($field['multiple']) { $form[$field['field_name']]['#type'] = 'fieldset'; @@ -57,8 +82,7 @@ function textfield_autocomplete_widget($ '#required' => ($delta == 0) ? $field['required'] : FALSE, '#maxlength' => $field['max_length'] ? $field['max_length'] : NULL, '#weight' => $field['widget']['weight'], - '#autocomplete_path' => - 'textfield_autocomplete/'.$field['field_name'], + '#autocomplete_path' => $autocomplete_path, ); if ($field['text_processing']) { $form[$field['field_name']][$delta]['format'] = filter_form($data['format'], $form[$field['field_name']][$delta]['value']['#weight'] + 1, array($field['field_name'], $delta, 'format')); @@ -74,8 +98,7 @@ function textfield_autocomplete_widget($ '#required' => ($delta == 0) ? $field['required'] : FALSE, '#maxlength' => $field['max_length'] ? $field['max_length'] : NULL, '#weight' => $field['widget']['weight'], - '#autocomplete_path' => - 'textfield_autocomplete/'.$field['field_name'], + '#autocomplete_path' => $autocomplete_path, ); if ($field['text_processing']) { $form[$field['field_name']][$delta]['format'] = filter_form($items[$delta]['format'], $form[$field['field_name']][$delta]['value']['#weight'] + 1, array($field['field_name'], $delta, 'format')); @@ -91,8 +114,7 @@ function textfield_autocomplete_widget($ '#description' => t($field['widget']['description']), '#maxlength' => $field['max_length'] ? $field['max_length'] : NULL, '#weight' => $field['widget']['weight'], - '#autocomplete_path' => - 'textfield_autocomplete/'.$field['field_name'], + '#autocomplete_path' => $autocomplete_path, ); if ($field['text_processing']) { $form[$field['field_name']][0]['format'] = filter_form($items[0]['format'], $form[$field['field_name']][0]['value']['#weight'] + 1, array($field['field_name'], 0, 'format'));