Projet

Général

Profil

Paste
Télécharger (2,12 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / bootstrap / templates / system / textfield.func.php @ 4eeb3b46

1
<?php
2
/**
3
 * @file
4
 * Stub file for bootstrap_textfield().
5
 */
6

    
7
/**
8
 * Returns HTML for a textfield form element.
9
 *
10
 * @param array $variables
11
 *   An associative array containing:
12
 *   - element: An associative array containing the properties of the element.
13
 *     Properties used: #title, #value, #description, #size, #maxlength,
14
 *     #required, #attributes, #autocomplete_path.
15
 *
16
 * @return string
17
 *   The constructed HTML.
18
 *
19
 * @see theme_textfield()
20
 *
21
 * @ingroup theme_functions
22
 */
23
function bootstrap_textfield($variables) {
24
  $element = $variables['element'];
25
  $element['#attributes']['type'] = 'text';
26
  element_set_attributes($element, array(
27
    'id',
28
    'name',
29
    'value',
30
    'size',
31
    'maxlength',
32
  ));
33
  _form_set_class($element, array('form-text'));
34

    
35
  $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
36

    
37
  $extra = '';
38
  if ($element['#autocomplete_path'] && !empty($element['#autocomplete_input'])) {
39
    drupal_add_library('system', 'drupal.autocomplete');
40
    $element['#attributes']['class'][] = 'form-autocomplete';
41

    
42
    $attributes = array();
43
    $attributes['type'] = 'hidden';
44
    $attributes['id'] = $element['#autocomplete_input']['#id'];
45
    $attributes['value'] = $element['#autocomplete_input']['#url_value'];
46
    $attributes['disabled'] = 'disabled';
47
    $attributes['class'][] = 'autocomplete';
48
    // Uses icon for autocomplete "throbber".
49
    if ($icon = _bootstrap_icon('refresh')) {
50
      $output = '<div class="input-group">' . $output . '<span class="input-group-addon">' . $icon . '</span></div>';
51
    }
52
    // Fallback to using core's throbber.
53
    else {
54
      $output = '<div class="input-group">' . $output . '<span class="input-group-addon">';
55
      // The throbber's background image must be set here because sites may not
56
      // be at the root of the domain (ie: /) and this value cannot be set via
57
      // CSS.
58
      $output .= '<span class="autocomplete-throbber" style="background-image:url(' . file_create_url('misc/throbber.gif') . ')"></span>';
59
      $output .= '</span></div>';
60
    }
61
    $extra = '<input' . drupal_attributes($attributes) . ' />';
62
  }
63

    
64
  return $output . $extra;
65
}