Basic Node object that we can rely on for Node objects in normal template tags. I created this because most of the tags we’ll be using will need both the form object and the helper string. This handles both the form object and parses out the helper string into attributes that templates can easily handle.
Returns a Context object with all the necesarry stuff for rendering the form
Parameters: |
|
---|
self.form and self.helper are resolved into real Python objects resolving them from the context. The actual_form can be a form or a formset. If it’s a formset is_formset is set to True. If the helper has a layout we use it, for rendering the form or the formset’s forms.
Returns a dictionary with all the parameters necessary to render the form/formset in a template.
Parameters: |
|
---|
Simulates a forloop tag, precisely:
{% for form in formset.forms %}
If {% uni_form %} is rendering a formset with a helper, We inject a ForLoopSimulator object in the context as forloop so that formset forms can do things like:
Fieldset("Item {{ forloop.counter }}", [...])
HTML("{% if forloop.first %}First form text{% endif %}"
Updates values as if we had iterated over the for
You need to pass in at least the form/formset object, and can also pass in the optional uni_form.helpers.FormHelper object.
helper (optional): A uni_form.helpers.FormHelper object.
Usage:
{% include uni_form_tags %}
{% uni_form my-form my_helper %}
Renders only form errors like django-uni-form:
{% load uni_form_tags %}
{{ form|as_uni_errors }}
Renders a form field like a django-uni-form field:
{% load uni_form_tags %}
{{ form.field|as_uni_field }}
The original and still very useful way to generate a uni-form form/formset:
{% load uni_form_tags %}
<form class="uniForm" action="post">
{% csrf_token %}
{{ myform|as_uni_form }}
</form>
Creates the <style> and <script> tags needed to initialize uni-form.
You can create a local uni-form/includes.html template if you want to customize how these files are loaded.
Only works with Django 1.3+