/** * Returns the SELECT in HTML * * @access public * @return string */ function toHtml() { //print_r($this->_values); $this->updateAttributes(array('multiple' => 'multiple')); if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { $tabs = $this->_getTabs(); $strHtml = ''; if ($this->getComment() != '') { $strHtml .= $tabs . '<!-- ' . $this->getComment() . " //-->\n"; } $myName = $this->getName(); $this->updateAttributes(array('id' => $myName)); // Workaround for not processing attributes arg properly load_js('modules/Libs/QuickForm/FieldTypes/automulti/automulti.js'); $searchElement = ''; $search = new HTML_QuickForm_autocomplete($myName . '__search', '', array('HTML_QuickForm_automulti', 'get_autocomplete_suggestbox'), array($this->_options_callback, $this->_options_callback_args, $this->_format_callback)); $search->setAttribute('placeholder', __('Start typing to search...')); $search->on_hide_js('if($("__autocomplete_id_' . $myName . '__search").value!=""){automulti_on_hide("' . $myName . '","' . $this->list_sep . '");' . $this->on_add_js_code . '}'); $searchElement .= $tabs . $search->toHtml() . "\n"; if (isset($this->_values[0]) && (preg_match('/' . addcslashes($this->list_sep, '/') . '/i', $this->_values[0]) || $this->_values[0] == '')) { $this->_values = explode($this->list_sep, $this->_values[0]); array_shift($this->_values); } $this->setName($myName . '__display'); $mainElement = ''; $list = ''; $attrString = $this->_getAttrString($this->_attributes); $mainElement .= $tabs . '<select' . $attrString . ' onclick="automulti_remove_button_update(\'' . $myName . '\');">' . "\n"; if ($this->_format_callback) { foreach ($this->_values as $value) { $mainElement .= $tabs . "\t" . '<option value="' . $value . '">' . call_user_func($this->_format_callback, $value, $this->_options_callback_args) . '</option>' . "\n"; $list .= '__SEP__' . $value; } } $mainElement .= $tabs . '</select>'; $strHtml .= $tabs . '<table class="automulti">'; $strHtml .= $tabs . '<tr>' . $tabs . '<td class="search-element">' . $searchElement . '</td>' . ($this->search_button ? $tabs . '<td class="search">' . $this->search_button . '</td>' : '<td></td>') . $tabs . '<td width="80px;" class="button disabled" id="automulti_button_style_' . $myName . '">' . '<input style="width:100%" type="button" onclick="automulti_remove_button_action(\'' . $myName . '\', \'' . $this->list_sep . '\');' . $this->on_remove_js_code . '" value="' . __('Remove') . '">' . '</td>' . '</tr>'; $strHtml .= $tabs . '<tr><td class="main-element" colspan="3">' . $mainElement . '</td></tr></table>'; $this->setName($myName); $strHtml .= $tabs . '<input type="hidden" name="' . $myName . '" value="' . $list . '" id="' . $myName . '__var_holder" />' . "\n"; return $strHtml; } }