示例#1
0
 /**
  * Add autocomplete JS code to head
  * @param string $htmlid of element to turn into autocomplete
  * @param int $elementid
  * @param string $plugin
  * @param array $opts (currently only takes 'onSelection')
  */
 public function autoComplete($htmlid, $elementid, $plugin = 'field', $opts = array())
 {
     FabrikHelperHTML::autoCompleteScript();
     $json = FabrikHelperHTML::autoCompletOptions($htmlid, $elementid, $plugin, $opts);
     $str = json_encode($json);
     FabrikHelperHTML::addScriptDeclaration("head.ready(function() { new FbAutocomplete('{$htmlid}', {$str}); });");
 }
示例#2
0
 function elementJavascriptOpts($repeatCounter)
 {
     $params =& $this->getParams();
     $element = $this->getElement();
     $opts = $this->_getOptionVals();
     $data =& $this->_form->_data;
     $arSelected = $this->getValue($data, $repeatCounter);
     $arVals = $this->getSubOptionValues();
     $arTxt = $this->getSubOptionLabels();
     $table = $params->get('join_db_name');
     $opts =& $this->getElementJSOptions($repeatCounter);
     $forms =& $this->getLinkedForms();
     $popupform = $params->get('databasejoin_popupform');
     $popuplistid = empty($popupform) || !isset($forms[$popupform]) ? '' : $forms[$popupform]->listid;
     $opts->id = $this->_id;
     $opts->key = $table . "___" . $params->get('join_key_column');
     $opts->label = $table . "___" . $params->get('join_val_column');
     $opts->formid = $this->getForm()->getForm()->id;
     $opts->listid = $popuplistid;
     $opts->value = $arSelected;
     $opts->defaultVal = $this->getDefaultValue($data);
     $opts->popupform = $popupform;
     $opts->popwiny = $params->get('yoffset', 0);
     $opts->display_type = $params->get('database_join_display_type', 'dropdown');
     $opts->windowwidth = $params->get('join_popupwidth', 360);
     $opts->displayType = $params->get('database_join_display_type', 'dropdown');
     $opts->show_please_select = $params->get('database_join_show_please_select');
     $opts->showDesc = $params->get('join_desc_column') === '' ? false : true;
     $opts->autoCompleteOpts = $opts->display_type == 'auto-complete' ? FabrikHelperHTML::autoCompletOptions($opts->id, $this->getElement()->id, 'databasejoin') : null;
     $opts->allowadd = $params->get('fabrikdatabasejoin_frontend_add', 0) == 0 ? false : true;
     if ($this->isJoin()) {
         $join =& $this->getJoin();
         $opts->elementName = $join->table_join;
         $opts->elementShortName = $element->name;
     }
     $opts = json_encode($opts);
     return $opts;
 }
示例#3
0
 /**
  * Add autocomplete JS code to head
  * @param string $htmlid of element to turn into autocomplete
  * @param int $elementid
  * @param string $plugin
  * @param array $opts (currently only takes 'onSelection')
  */
 public function autoComplete($htmlid, $elementid, $plugin = 'fabrikfield', $opts = array())
 {
     FabrikHelperHTML::autoCompleteScript();
     $json = FabrikHelperHTML::autoCompletOptions($htmlid, $elementid, $plugin, $opts);
     $str = FastJSON::encode($json);
     FabrikHelperHTML::addScriptDeclaration("window.addEvent('domready', function() { new FabAutocomplete('{$htmlid}', {$str}); });");
 }