mlavin/django-selectable — pull request #121 by Maillol (2014-04-05 11:00:39+00:00)
Title:  Automate Chained Selection

How to have Chained Selection without write javascript.
============================================

1) Defining simple lookup:

```python
class CityLookup(ModelLookup):
model = City
search_fields = ('name__icontains', )

def get_item_label(self, item):
return "%s, %s" % (item.name, item.state)
```

2) Defining form and declare the fields dependencys with __chained_field decorator__:

```python
@chained_field('city', 'state')
class ChainedForm(forms.Form):
city = selectable.AutoCompleteSelectField(
lookup_class=CityLookup,
label='City',
required=False,
widget=selectable.AutoComboboxSelectWidget
)
state = USStateField(widget=USStateSelect, required=False)
```

3) Use __bind_chained_form tag__ in template:

```python
{% extends "base.html" %}
{% load selectable_tags %}
{% block content %}
{{ form.as_p }}
{% endblock %}
{% block extra-js %}

{% endblock %}
```

Git message commit:
=================

Add 'chained_field' decorator for the Form class. This decorator allow to declare depedency between two fiels. Add 'bind_chained_form' templatetag to generate
JavaScript in order to send new parameters to a lookup. Add 'ChainedFormRegistry'
when 'chained_field' decorator is used on the class form, the form and
the fields are registered in the 'ChainedFormRegistry'. When 'bind_chained_form' templatetag
is called, it get informations in 'ChainedFormRegistry' in order to generate JavaScript.
Update exemple.

Best regard
Vincent