开发者

Complex form widgets in Django

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


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/


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜