Jelix 1.7.18

autocomplete_htmlFormWidget extends WidgetBase
in package

Widget allowing to select a value by showing results from a search after the user starts to type a name. The search is made into a select html element filled by the datasource of the control, which should be a menulist.

See jAutocomplete jqueryui plugin, which is base on the autocomplete plugin.

If the select box may contain hundred values, prefer to use the autocompleteajax_html widget.

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 dao="mymodule~mydao"/>
    </menulist>

In a template:

{form $form, $submitAction, $submitParam, 'html', array('plugins'=>array(
     'mylist'=>'autocomplete_html'))}

{formcontrols}
   ... {ifctrl 'mylist'}{ctrl_control '', array(
         'attr-autocomplete'=>array('style'=>'width:40em;')}
       {else}{ctrl_control}{/ifctrl}
{/formcontrols}

Table of Contents

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

Methods

displayAutocompleteInput()

protected displayAutocompleteInput(array<string|int, mixed> $attrAutoComplete, array<string|int, mixed> $attrSelect, string $value, null|string $emptyLabel) : mixed
Parameters
$attrAutoComplete : array<string|int, mixed>
$attrSelect : array<string|int, mixed>
$value : string
$emptyLabel : null|string

null if an empty item should not be shown

Return values
mixed

displaySelectChoices()

protected displaySelectChoices(array<string|int, mixed> $attrSelect, string $value, null|string $emptyLabel) : mixed
Parameters
$attrSelect : array<string|int, mixed>
$value : string
$emptyLabel : null|string

null if an empty item should not be shown

Return values
mixed

Search results