API Documentation

deform_ext_autocomplete.includeme(config)

If you use Pyramid, call this function to enable the widget or add “deform_ext_autocomplete” in the pyramid.includes directive of your Pyramid configuration file.

class deform_ext_autocomplete.ExtendedAutocompleteInputWidget(*args, **kwargs)

Render an <input type="text"/> widget which provides autocompletion via a list of values.

Contrary to deform.widget.AutocompleteInputWidget, it can store a value that is different from the one it displays. The attributes and arguments are the same as those of deform.widget.AutocompleteInputWidget except the following ones which replace or add to the former:

Attributes/Arguments

template
The template name used to render the widget. Default: autocomplete_input_w_hidden.
readonly_template
The template name used to render the widget in read-only mode. Default: readonly/autocomplete_input_w_hidden.
values
Either an iterable that can be converted to a JSON array, or a string representing a URL. If the latter, an XMLHTTPRequest will be sent to this URL to retrieve a JSON serialization of an iterable. In either case, each value of the iterable must be an associative array that has at least two keys: stored and displayed. Both values must be strings. An optional dropdown key may be provided, in which case it will be used in the dropdown that appears when the user starts typing characters in the text input widget. Default: () (the empty tuple).
display_value
A callable that accepts two arguments: the field and the cstruct (which usually corresponds to the value that is to be stored – see Colander documentation for further details). This callable should return a string or unicode object that will be displayed in the visible text input field once the user has selected an item. Note that cstruct may be the empty string when the field has not been filled. Default: lambda widget, field, cstruct: cstruct
strip
If true, during deserialization, strip the value of leading and trailing whitespace. Default: True.
min_length
min_length is the number of characters to wait for before activating the autocomplete call. Default: 1.
delay
delay is the number of milliseconds to wait for before activating the autocomplete call. Default: 400 (ms) if values are fetched via AJAX, 10 (ms) otherwise.