from django import newforms as forms from django.conf import settings from django.newforms.forms import BoundField, pretty_name from django.newforms import widgets, fields from django.template import Context, loader from nidvid.utils import output_debug class TemplatedForm(forms.Form): def as_template(self): "Helper function for fieldsting fields data from form." bound_fields = [BoundField(self, field, name) for name, field in self.fields.items()] c = Context(dict(form = self, bound_fields = bound_fields)) # TODO: check for template ... if template does not exist # we could just get_template_from_string to some default # or we could pass in the template name ... whatever we want t = loader.get_template('newforms/form.html') return t.render(c) def as_custom(self): "Returns this form rendered as HTML
%s: | %s |
---|