You are here

function theme_finder_autocomplete_textfield in Finder 6

Same name and namespace in other branches
  1. 7.2 plugins/element_handler/autocomplete.inc \theme_finder_autocomplete_textfield()
  2. 7 modules/finder_autocomplete/finder_autocomplete.module \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

$element: The Forms API form element.

File

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

Code

function theme_finder_autocomplete_textfield($element) {
  $size = empty($element['#size']) ? '' : ' size="' . $element['#size'] . '"';
  $maxlength = empty($element['#maxlength']) ? '' : ' maxlength="' . $element['#maxlength'] . '"';
  $class = array(
    'form-text',
  );
  $extra = '';
  $output = '';
  if (menu_valid_path(array(
    'link_path' => $element['#autocomplete_path'],
  ))) {
    $module = 'finder_autocomplete';
    drupal_add_js(drupal_get_path('module', $module) . '/' . $module . '.js');
    $class[] = 'form-autocomplete';
    $extra = '<input class="finder-autocomplete" type="hidden" id="' . $element['#id'] . '-autocomplete" value="' . check_url(url($element['#autocomplete_path'], array(
      'absolute' => TRUE,
    ))) . '" disabled="disabled" />';
  }
  _form_set_class($element, $class);
  if (isset($element['#field_prefix'])) {
    $output .= '<span class="field-prefix">' . $element['#field_prefix'] . '</span> ';
  }
  $output .= '<input type="text"' . $maxlength . ' name="' . $element['#name'] . '" id="' . $element['#id'] . '"' . $size . ' value="' . check_plain($element['#value']) . '"' . drupal_attributes($element['#attributes']) . ' />';
  if (isset($element['#field_suffix'])) {
    $output .= ' <span class="field-suffix">' . $element['#field_suffix'] . '</span>';
  }
  return theme('form_element', $element, $output) . $extra;
}