1 <?php
 2  3  4  5  6  7  8 
 9 
10 defined('JPATH_PLATFORM') or die;
11 
12 JFormHelper::loadFieldClass('list');
13 
14 15 16 17 18 19 
20 class JFormFieldCombo extends JFormFieldList
21 {
22     23 24 25 26 27 
28     protected $type = 'Combo';
29 
30     31 32 33 34 35 36 
37     protected function getInput()
38     {
39         $html = array();
40         $attr = '';
41 
42         
43         $attr .= !empty($this->class) ? ' class="combobox ' . $this->class . '"' : ' class="combobox"';
44         $attr .= $this->readonly ? ' readonly' : '';
45         $attr .= $this->disabled ? ' disabled' : '';
46         $attr .= !empty($this->size) ? ' size="' . $this->size . '"' : '';
47         $attr .= $this->required ? ' required aria-required="true"' : '';
48 
49         
50         $attr .= $this->onchange ? ' onchange="' . $this->onchange . '"' : '';
51 
52         
53         $options = $this->getOptions();
54 
55         
56         JHtml::_('behavior.combobox');
57 
58         $html[] = '<div class="combobox input-append">';
59 
60         
61         $html[] = '<input type="text" name="' . $this->name . '" id="' . $this->id . '" value="'
62             . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $attr . ' autocomplete="off" />';
63 
64         $html[] = '<div class="btn-group">';
65         $html[] = '<button type="button" class="btn dropdown-toggle">';
66         $html[] = '     <span class="caret"></span>';
67         $html[] = '</button>';
68 
69         
70         $html[] = '<ul class="dropdown-menu">';
71 
72         foreach ($options as $option)
73         {
74             $html[] = '<li><a href="#">' . $option->text . '</a></li>';
75         }
76 
77         $html[] = '</ul>';
78 
79         $html[] = '</div></div>';
80 
81         return implode($html);
82     }
83 }
84