Skip to content
This repository has been archived by the owner on Sep 18, 2022. It is now read-only.

Commit

Permalink
Thanks to bmihelac for the fix, this fixes issue #GH-90
Browse files Browse the repository at this point in the history
  • Loading branch information
maraujop committed Sep 17, 2011
1 parent 0f1ba29 commit 2f57d6c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions uni_form/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class Fieldset(object):

def __init__(self, legend, *fields, **kwargs):
self.fields = list(fields)
self.legend = Template(legend)
self.legend = unicode(legend)

This comment has been minimized.

Copy link
@bmihelac

bmihelac Sep 17, 2011

Contributor

If we use unicodehere, lazy translation string would be translated when this fieldset is created and not when it is rendered.
Isn't it maybe too early?

This comment has been minimized.

Copy link
@maraujop

maraujop Sep 17, 2011

Author Collaborator

Good point, I've tried dev on a project full of i18n and it works this way. So I guess it's late enough this way and probably this unloads some work when rendering, right?

This comment has been minimized.

Copy link
@bmihelac

bmihelac Sep 17, 2011

Contributor

As long as helper is defined as a property of a form, it is initiated every time it is called.

I do not have any helper defined outside of a form for now but can imagine it happen for some reason.

This comment has been minimized.

Copy link
@maraujop

maraujop Sep 17, 2011

Author Collaborator

Most of my helpers are static variables of the form. So they behave like a Singleton, they get created first time a form is instantiated and then reused. This is the way that best performs if you don't manipulate helpers in your views. All this has been updated in 0.9.0 docs. So I guess leaving it like this is ok. Thanks for paying so much attention.

This comment has been minimized.

Copy link
@bmihelac

bmihelac Sep 17, 2011

Contributor

ok, i will check it later on 0.9.0

best

self.css_class = kwargs.get('css_class', '')
self.css_id = kwargs.get('css_id', None)
# Overrides class variable with an instance level variable
Expand All @@ -177,7 +177,9 @@ def render(self, form, form_style, context):
for field in self.fields:
fields += render_field(field, form, form_style, context)

legend = u'%s' % self.legend.render(context)
legend = ''
if self.legend:
legend = u'%s' % Template(self.legend).render(context)
return render_to_string(self.template, Context({'fieldset': self, 'legend': legend, 'fields': fields, 'form_style': form_style}))


Expand Down

0 comments on commit 2f57d6c

Please sign in to comment.