Widget documentation
====================


Autocomplete
------------

The ``AutocompleteInput`` widget hooks up a regular text input widget with
`jquery-ui's autocomplete <http://jqueryui.com/demos/autocomplete/>`_.  It
currently hooks up jquery's autocomplete with a url that provides the
necessary data (see jquery's `remote datasource demo
<http://jqueryui.com/demos/autocomplete/#remote>`_.

The url should accept a ``term`` ``GET`` parameter and return a json list of
dictionaries.  The dictionaries must have the key "value" and/or "label".  If
one of them is missing, the other is used twice.  The label is the
user-visible string and the value is the value being put into the form data.

You can pass the widget either a ``url`` (just the url to be called) or a
``urlname`` (a name that's looked up in the urlconf).


Example usage::

  from django import forms
  from rays.widgets import AutocompleteInput


  class AnimalForm(forms.Form):
      name = forms.CharField(
          label=_('Enter animal name'),
          max_length=50,
          widget=AutocompleteInput(urlname='autocomplete-animals'))


Datepicker
----------

The ``DatepickerInput`` widget hooks up a regular text input widget with
`jquery's datepicker <http://jqueryui.com/demos/datepicker/>`_.


Example usage::

  from django import forms
  from rays.widgets import DatepickerInput


  class DatepickerForm(forms.Form):
      start_date = forms.DateField(widget=DatepickerInput())
      end_date = forms.DateField(widget=DatepickerInput(format='%Y.%m.%d'))

