Skip to content

Commit

Permalink
Turning {{ form_html }} variable into an attribute of the form, so it…
Browse files Browse the repository at this point in the history
…'s more consistent with the formset situation.
  • Loading branch information
maraujop committed May 19, 2011
1 parent 8bc66a5 commit aae9e24
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions uni_form/templates/uni_form/whole_uni_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
{% csrf_token %}
{% endif %}

{% if form_html %}
{% if form.form_html %}
{% include "uni_form/errors.html" %}
{{ form_html }}
{{ form.form_html }}
{% else %}
{% include "uni_form/uni_form.html" %}
{% endif %}
Expand Down
15 changes: 7 additions & 8 deletions uni_form/templatetags/uni_form_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ def get_render(self, context):
is_formset = isinstance(actual_form, BaseFormSet)
response_dict = self.get_response_dict(attrs, context, is_formset)

# If we have a helper's layout we use it
form_html = ""
if helper and helper.layout and not is_formset:
form_html = helper.render_layout(actual_form, attrs['form_style'])
elif helper and helper.layout and is_formset:
for form in actual_form.forms:
form.form_html = helper.render_layout(form, attrs['form_style'])
# If we have a helper's layout we use it, for the form or the formset's form
if helper and helper.layout:
if not is_formset:
actual_form.form_html = helper.render_layout(actual_form, attrs['form_style'])
else:
for form in actual_form.forms:
form.form_html = helper.render_layout(form, attrs['form_style'])

if is_formset:
response_dict.update({'formset': actual_form})
Expand All @@ -77,7 +77,6 @@ def get_render(self, context):

response_dict.update({
'is_formset': is_formset,
'form_html': form_html,
})

return Context(response_dict)
Expand Down

0 comments on commit aae9e24

Please sign in to comment.