views:

106

answers:

2

I am looking for good helper libraries to generate a rather complex form in Django.

  • Dynamic field dependencies: Say if option a is selected certain fields are shown/hidden and subset of these are mandatory depending on option selection.

  • Add more: On clicking "Add more" button that clones some widget.

This is something which ToscaWidgets is capable of handle.

Currently I am managing this with some jquery code however not completely satisfied. And sadly cant use ToscaWidgets for some reason.

TIA

+2  A: 

I've used a heavily customized Formset to make a rather complicated form with complicated user permission dependencies. This involved subclassing django.forms.formsets.BaseFormSet, overriding __init__, add_fields, is_valid, and save, and of course using a customized Form. The end-product was a bit hairy, but I'm still able to understand and modify it after 6 months or so.

I didn't make use of the Formset ability to work with adding and subtracting subforms, but this should meet your needs.

Documentation at: http://docs.djangoproject.com/en/1.1/topics/forms/formsets/

David Eyk
A: 

After searching a little more I found one solution. django-dynamic-formset based on django formsets solves the purpose. Impressive work

PS: Will try to add some screenshots later.

Shekhar