Skip to content

Commit

Permalink
Removing i18n tags. Removing uni_form_tags where possible, using incl…
Browse files Browse the repository at this point in the history
…udes instead for making context available in the included template.

This way if `form_error_title` or `formset_error_title` are context variables,
they will be available to the included templates, while using filters this wasn't possible.
At the same time we keep DRY, like using filters.

Templates might be a little bit harder to follow now if somebody is not familiar with its
hierarchy.
  • Loading branch information
maraujop committed May 18, 2011
1 parent ec6cf9e commit 2e633ce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion uni_form/templates/uni_form/errors.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% if form.non_field_errors %}
<div id="errorMsg">
{% if error_message_title %}<h3>{{ form_error_title }}</h3>{% endif %}
{% if form_error_title %}<h3>{{ form_error_title }}</h3>{% endif %}
<ol>
{{ form.non_field_errors|unordered_list }}
</ol>
Expand Down
2 changes: 1 addition & 1 deletion uni_form/templates/uni_form/uni_formset.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{{ formset.management_form|as_uni_form }}
{% for form in formset.forms %}
<div class="multiField">
{{ form|as_uni_form }}
{% include 'uni_form/uni_form.html' %}
</div>
{% endfor %}
11 changes: 4 additions & 7 deletions uni_form/templates/uni_form/whole_uni_form.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{% load uni_form_tags i18n %}

{% if form_tag %}<form action="{{ form_action|lower }}" class="uniForm{% if form_class %} {% endif %}{{ form_class }}" method="{{ form_method }}"{% if form_id %} id="{{ form_id }}"{% endif %}{% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>{% endif %}
{% if form_tag %}<form action="{{ form_action|lower }}" class="uniForm{% if form_class %} {{ form_class }}{% endif %}" method="{{ form_method }}"{% if form_id %} id="{{ form_id }}"{% endif %}{% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>{% endif %}
{% if form_method|lower == 'post' %}
{% csrf_token %}
{% endif %}

{{ form|as_uni_errors }}

{% if form_html %}
{% include "uni_form/errors.html" %}
{{ form_html }}
{% else %}
{{ form|as_uni_form }}
{% include "uni_form/uni_form.html" %}
{% endif %}

{% if inputs %}
<div class="buttonHolder">
{% for input in inputs %}
<input type="{{ input.input_type }}"
<input type="{{ input.input_type }}"
name="{{ input.name|slugify }}"
value="{{ input.value }}"
{% ifnotequal input.input_type "hidden" %}
Expand Down
8 changes: 4 additions & 4 deletions uni_form/templates/uni_form/whole_uni_formset.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load uni_form_tags i18n %}
{% load uni_form_tags %}

{% if formset_tag %}
<form action="{{ formset_action }}" class="uniForm {{ formset_class }}" method="{{ formset_method }}" {% if formset_id %}id="{{ formset_id }}"{% endif %}{% if formset.is_multipart %} enctype="multipart/form-data"{% endif %}>
Expand All @@ -11,14 +11,14 @@
{{ formset.management_form|as_uni_form }}
</div>

{{ formset|as_uni_errors }}
{% include "uni_form/errors_formset.html" %}

{% for form in formset.forms %}
{% if form.form_html %}
{{ form|as_uni_errors }}
{% include "uni_form/errors.html" %}
{{ form.form_html }}
{% else %}
{{ form|as_uni_form }}
{% include "uni_form/uni_form.html" %}
{% endif %}
{% endfor %}

Expand Down

0 comments on commit 2e633ce

Please sign in to comment.