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.
http://toscawidgets.org/documentation/tw.dynforms/tutorial.html#growing
Some working ToscaWidgets Demos
Currently I am managing this with some jquery code however not completely satisfied. And sadly cant use ToscaWidgets for some reason.
TIA
A widget is Django's representation of an HTML input element. The widget handles the rendering of the HTML, and the extraction of data from a GET/POST dictionary that corresponds to the widget. The HTML generated by the built-in widgets uses HTML5 syntax, targeting <!
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With