[Grok-dev] Access to widgets, actions and errors in grok forms
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Tue Jan 23 08:01:24 EST 2007
Hi,
Grok currently hides some (most) of zope.formlib's implementation by
way of grok.Edit/Add/DisplayForm. However, when you're writing you own
pagetemplates for rendering the form, you'd want access to
zope.formlib.form.FormBase's errors, widgets, and actions attributes.
For errors and widgets I can imagine this patch:
Index: grok/components.py
===================================================================
--- grok/components.py (revision 72171)
+++ grok/components.py (working copy)
@@ -348,6 +348,9 @@
form = self.form
form.update()
+ self.errors = form.errors
+ self.widgets = form.widgets
+ self.actions = form.actions
# this code is extracted and modified from form.render
However, I'm not sure about the self.actions assignment because
formlib's action decorator is doing some sys._getframe() trickery I do
not really understand in order to append action methods to the form
instance's actions "attribute" (by lack of a better name, see the
implementation in zope.formlib.form.action).
It seems to work though. This could all be sufficient for now, but
maybe we can come up with better ideas?
kind regards,
jw
--
Jan-Wijbrand Kolman
More information about the Grok-dev
mailing list