Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

autocomplete-field.inc.php

Go to the documentation of this file.
00001 <?
00013 class AutoCompleteField extends TextField
00014 {
00015     public $lookupUrl = null;
00016     public $minChars = 1;
00017     public $indicator = true;
00018     public $indicatorUrl = '/lib/img/ajax/loading-blue.gif';
00019     public $updateElement = null;
00020     public $afterUpdateElement = null;
00021     
00022     public function __construct($name, Form &$parentForm, array $attribs = array())
00023     {
00024         $this->id = $this->name;
00025 
00026         if ($attribs['lookupUrl'])
00027         {
00028             $this->lookupUrl = $attribs['lookupUrl'];
00029             unset($attribs['lookupUrl']);
00030         }
00031         else
00032             throw new Exception("Expected parameter 'lookupUrl' for AutoComplete Field.");
00033         
00034         parent::__construct($name, $parentForm, $attribs);
00035     }
00036 
00037     public function drawInput()
00038     {
00039         parent::drawInput();
00040 ?>
00041         <span id="<?=$this->name?>_indicator" class="AjaxLoadIndicator" style="display: none"><img src="<?=$this->indicatorUrl?>" alt="Loading..." /></span> 
00042         <div id="<?=$this->name?>_choices" class="autocomplete"></div>
00043         <script>
00044             new Ajax.Autocompleter('<?=$this->name?>', '<?=$this->name?>_choices', '<?=$this->lookupUrl?>', {
00045                 paramName: 'like',
00046                 minChars: <?=$this->minChars?>,
00047                 <? if ($this->indicator){ ?> indicator: '<?=$this->name?>_indicator', <?}?>
00048             });
00049         </script>
00050 <?
00051 /*
00052                 <? if ($this->indicator)
00053                 indicator: <?=(string)$this->indicator?>,
00054                 updateElement: <?=(string)$this->updateElement?>,
00055                 afterUpdateElement: <?=(string)$this->afterUpdateElement?>
00056 */
00057     }
00058 }
00059 ?>

Generated on Fri Oct 27 12:26:39 2006 for BaseJumper by doxygen 1.3.9.1