Skip to content

icms_ipf_form_elements_Autocomplete

Raimondas Rimkevičius edited this page Mar 9, 2020 · 1 revision
Notice: Wiki was automatic generated from project sources as project API documentation. Do not edit manually!

icms_ipf_form_elements_Autocomplete

To make the Autocomplete field work, the include file needs to look like the following (in this example the Autocomplete field would use the conf_name field of the config table as a lookup):

icms::$logger->disableLogger(); $sql = "SELECT * FROM " . icms::$xoopsDB->prefix("config") . " WHERE conf_name LIKE '%" . $_GET['term'] . "%'"; $result = icms::$xoopsDB->query($sql); while ($myrow = icms::$xoopsDB->fetchArray($result)) $ret[] = array("item" => $myrow["conf_name"]); echo $_GET["callback"] . "(" . json_encode($ret) . ")";

Important:

  • use control parameter "file" to specify the include file for the autocomplete
  • the include file must be specified without ICMS_URL or ICMS_ROOT_PATH
  • if the include file does not exist, the form field is displayed as a text field
  • use control parameter "minlength" to specify the minimum amount of characters before the autocomplete function starts to work (default: 3)
  • use control parameter "delay" to specify the delay before the autocomplete function starts to work. Use with caution since it can result in high server load! (default: 500)

Properties

$_file

private mixed $_file
  • Visibility: private

$_size

private int $_size

Size

  • Visibility: private

$_maxlength

private int $_maxlength

Maximum length of the text

  • Visibility: private

$_value

private string $_value

Initial text

  • Visibility: private

$autocomplete

public bool $autocomplete = \false

Turns off the browser autocomplete function.

  • Visibility: public

Methods

__construct

mixed icms_form_elements_Text::__construct(string caption, string name, int size, int maxlength, string value, mixed autocomplete)

Constructor

Arguments

  • caption string - <p>Caption</p>
  • name string - <p>"name" attribute</p>
  • size int - <p>Size</p>
  • maxlength int - <p>Maximum length of text</p>
  • value string - <p>Initial text</p>
  • autocomplete mixed

render

string icms_form_elements_Text::render()

Prepare HTML for output

getSize

int icms_form_elements_Text::getSize()

Get size

getMaxlength

int icms_form_elements_Text::getMaxlength()

Get maximum text length

getValue

string icms_form_elements_Text::getValue(bool encode)

Get initial content

Arguments

  • encode bool - <p>To sanitizer the text? Default value should be "true"; however we have to set "false" for backward compat</p>

setValue

mixed icms_form_elements_Text::setValue(value)

Set initial text value

Arguments

  • value mixed - <p>string</p>
Clone this wiki locally