[Checkins] SVN: plone.z3cform/trunk/plone/z3cform/layout.py Look up
label on the form *instance*, not the class. Without this,
it's impossible to use a property to define a dynamic label on the
form.
Martin Aspeli
optilude at gmx.net
Sun Aug 3 15:24:17 EDT 2008
Log message for revision 89310:
Look up label on the form *instance*, not the class. Without this, it's impossible to use a property to define a dynamic label on the form.
Changed:
U plone.z3cform/trunk/plone/z3cform/layout.py
-=-
Modified: plone.z3cform/trunk/plone/z3cform/layout.py
===================================================================
--- plone.z3cform/trunk/plone/z3cform/layout.py 2008-08-03 19:15:41 UTC (rev 89309)
+++ plone.z3cform/trunk/plone/z3cform/layout.py 2008-08-03 19:24:16 UTC (rev 89310)
@@ -42,16 +42,23 @@
Override this method if you need to pass a different context
to your form, or if you need to render a number of forms.
"""
- form = self.form(self.context.aq_inner, self.request)
- form.__name__ = self.__name__
- return form()
+ return self._form()()
def label(self):
"""Override this method to use a different way of acquiring a
label or title for your page. Overriding this with a simple
attribute works as well.
"""
- return self.form.label
+ return self._form().label
+
+ def _form(self):
+ form = getattr(self, '_cached_form', None)
+ if form is not None:
+ return form
+ self._cached_form = self.form(self.context.aq_inner, self.request)
+ self._cached_form.__name__ = self.__name__
+ return self._cached_form
+
def wrap_form(form, __wrapper_class=FormWrapper, **kwargs):
class MyFormWrapper(__wrapper_class):
More information about the Checkins
mailing list