Hi Tim,

Tim Knapp schrieb:
On Fri, 2009-02-13 at 02:20 +0100, Carsten Senger wrote:
Tim Knapp schrieb:
I would like to use plone.z3cform in a viewlet but I'd also like to add
some descriptive text beside the widget as well as some other
miscellaneous TAL/HTML. In order to render the widgets in the
plone.z3cform how do I get access to them, are they available from the
'view' object somehow or by some other means? I'm also assuming to
render the widget (once I've got it), I just call the widget.render()
method?
<tal:r replace="structure python:view.widgets['message'].render()" />

You need to use your own layout cause the standard form wrapper wraps the form into the main_template.
This should work (untested):

from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile

layout = ViewPageTemplateFile('mylayout.pt')

wrap_form(my_unwrapped_form, index=layout)

This works great thanks. Only problem is when I do the view.widgets call
in the template I get an AttributeError as per this traceback[1]. Why
isn't view.widgets available? It renders fine without the 'layout'.

Thanks,
Tim

[1] http://paste.plone.org/26350

I think you placed the render call in the layout pagetemplate, then the view is the FormWrapper, not the wrapped form:

> 86.  'view': <Products.Five.viewlet.metaconfigure.MyFormWrapper
>               object at 0xd46666c>,

The layout pagetemplate should contain a striped down version of plone.app.form's layout.pt that only calls view/contents (view is the form view that you wrap).

In your form view you set another template that holds a <form> tag and the widget calls:

from zope.app.pagetemplate import ViewPageTemplateFile

class MyForm(...):
   template = ViewPageTemplateFile('myformtemplate.pt')

Note that the template for the wrapper (layout.pt) has to be an acquisition aware pagetemplate from Five, and the form itself needs a plain pagetemplate form zope.app.

..Carsten

_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to