pytask/templatetags/form_helpers.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Sun, 23 Jan 2011 03:21:42 +0530
changeset 515 5a90ac22843d
parent 431 fcc87a3f0311
permissions -rw-r--r--
Style fix.

"""Module containing the templatetags for constructing forms.
"""


__authors__ = [
    '"Madhusudan.C.S" <madhusudancs@fossee.in>',
    ]


from django import template


register = template.Library()


@register.inclusion_tag('templatetags/_as_div_form.html')
def as_div_form(form, form_name, csrf_token, button_label,
                action_url='', file_support=False):
    """Returns a form to be constructed by the template specified.
    """

    return {
      'form': form,
      'form_name': form_name,
      'csrf_token': csrf_token,
      'action_url': action_url,
      'button_label': button_label,
      'file_support': file_support,
    }


@register.inclusion_tag('templatetags/_as_div_field.html')
def as_div_field(field):
    """Returns the field for each div form field.
    """

    return {
      'field': field,
      }