Jelix 1.8.9

autocompleteajax_htmlFormWidget extends WidgetBase
in package

Widget allowing to select a value by showing results from a search after the user start to type a name. The search is made by doing an http request to the server. See jAutocompleteAjax jqueryui plugin, which is base on the autocomplete plugin.

You should use a menulist control, and a datasource, inheriting from jFormsDaoDatasource or jFormsDynamicDatasource, and having a getData() method returning an empty list.

The widget accepts a specific attribute, 'attr-autocomplete', an array which should contains at least an item 'source' indicating the url of the search engine. The array may contains other attributes for the input element used to type the search term (class, style..).

example of use:

In the form file:

    <menulist ref="mylist"> <label>test</label>
    <datasource class="mymodule~mydatasource"/>

The datasource:

class mydatasource extends jFormsDaoDatasource {
   function __construct($formId) {
      parent::__construct ("mymodule~myDao" , "findAll" , "label", 'id');
   public function getData($form) { return array(); }

In a template:

{form $form, $submitAction, $submitParam, 'html', array('plugins'=>array(

   ... {ifctrl 'mylist'}{ctrl_control '', array(

Table of Contents

outputControl()  : mixed
outputMetaContent()  : mixed
displayAutocompleteInput()  : mixed
outputJs()  : mixed



protected displayAutocompleteInput(array<string|int, mixed> $attrAutoComplete, array<string|int, mixed> $attrHidden) : mixed
$attrAutoComplete : array<string|int, mixed>
$attrHidden : array<string|int, mixed>

attributes for the hidden input that will contain the selected value

Return values

Search results