From: Magnus Hagander Date: Wed, 30 Jan 2013 13:01:25 +0000 (+0100) Subject: Add ability to toggle fields in forms X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=3818de50c509f13f6679d646d290dc5c88635e2e;p=pgweb.git Add ability to toggle fields in forms This uses jQuery to make it possible to enable and disable fields in the default forms, by specifying an attribute on the form class. The form class still has to implement proper validators, so it does not rely on client side validations. --- diff --git a/pgweb/util/helpers.py b/pgweb/util/helpers.py index 831cb058..817f416e 100644 --- a/pgweb/util/helpers.py +++ b/pgweb/util/helpers.py @@ -57,6 +57,7 @@ def simple_form(instancetype, itemid, request, formclass, formtemplate='base/for 'formitemtype': instance._meta.verbose_name, 'markdownfields': markdownfields, 'form_intro': hasattr(form, 'form_intro') and form.form_intro or None, + 'toggle_fields': hasattr(form, 'toggle_fields') and form.toggle_fields or None, 'savebutton': (itemid == "new") and "New" or "Save", 'operation': (itemid == "new") and "New" or "Edit", }, NavContext(request, navsection)) diff --git a/templates/base/form.html b/templates/base/form.html index ec90bbf6..3cc4e472 100644 --- a/templates/base/form.html +++ b/templates/base/form.html @@ -53,6 +53,33 @@ {%endfor%} } +{%if toggle_fields%} + + +{%endif%} {%endif%} {%endblock%}