• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/ZendX/JQuery/View/Helper/AutoComplete.php

00001 <?php
00026 require_once "ZendX/JQuery/View/Helper/UiWidget.php";
00027 
00037 class ZendX_JQuery_View_Helper_AutoComplete extends ZendX_JQuery_View_Helper_UiWidget
00038 {
00057     public function autoComplete($id, $value = null, array $params = array(), array $attribs = array())
00058     {
00059         $attribs = $this->_prepareAttributes($id, $value, $attribs);
00060 
00061         if (!isset($params['source'])) {
00062             if (isset($params['url'])) {
00063                 $params['source'] = $params['url'];
00064                 unset($params['url']);
00065             } else if (isset($params['data'])) {
00066                 $params['source'] = $params['data'];
00067                 unset($params['data']);
00068             } else {
00069                 require_once "ZendX/JQuery/Exception.php";
00070                 throw new ZendX_JQuery_Exception(
00071                     "Cannot construct AutoComplete field without specifying 'source' field, ".
00072                     "either an url or an array of elements."
00073                 );
00074             }
00075         }
00076 
00077         $params = ZendX_JQuery::encodeJson($params);
00078 
00079         $js = sprintf('%s("#%s").autocomplete(%s);',
00080                 ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
00081                 $attribs['id'],
00082                 $params
00083         );
00084 
00085         $this->jquery->addOnLoad($js);
00086 
00087         return $this->view->formText($id, $value, $attribs);
00088     }
00089 }

Generated on Thu Apr 19 2012 17:01:18 for openbiz by  doxygen 1.7.2