You are here

function theme_finder_autocomplete_textfield in Finder 7

Same name and namespace in other branches
  1. 6 modules/finder_autocomplete/finder_autocomplete.module \theme_finder_autocomplete_textfield()
  2. 7.2 plugins/element_handler/autocomplete.inc \theme_finder_autocomplete_textfield()

Format an autocomplete that autosubmits.

This was a result of user dissatisfaction with the default Drupal autocomplete method and allows for some of the configuration options that come with Autocomplete to function properly. The regular autocomplete textfields in finder just use theme_textfield by default.

Parameters

$variables: An array with keys: 'element' - The Forms API form element.

File

modules/finder_autocomplete/finder_autocomplete.module, line 311
The finder autocomplete module.

Code

function theme_finder_autocomplete_textfield($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'text';
  element_set_attributes($element, array(
    'id',
    'name',
    'value',
    'size',
    'maxlength',
  ));
  _form_set_class($element, array(
    'form-text',
  ));
  $extra = '';
  if (!empty($element['#autocomplete_path']) && drupal_valid_path($element['#autocomplete_path'])) {
    $module = 'finder_autocomplete';
    drupal_add_js(drupal_get_path('module', $module) . '/' . $module . '.js');
    $element['#attributes']['class'][] = 'form-autocomplete';
    $attributes = array();
    $attributes['type'] = 'hidden';
    $attributes['id'] = $element['#attributes']['id'] . '-autocomplete';
    $attributes['value'] = url($element['#autocomplete_path'], array(
      'absolute' => TRUE,
    ));
    $attributes['disabled'] = 'disabled';
    $attributes['class'][] = 'finder-autocomplete';
    $extra = '<input' . drupal_attributes($attributes) . ' />';
  }
  $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
  return $output . $extra;
}