[Product-Developers] Re: z3c form in a viewlet

Daniel Nouri daniel.nouri at gmail.com
Tue Oct 21 12:44:53 UTC 2008


cswank writes:

> Hello all,
> I just got my first zc3.form working, and now I would like to display it in
> a viewlet.  The tutorial I followed
> (http://plone.org/documentation/how-to/easy-forms-with-plone3) mentioned
> that it is possible to use the form in a viewlet, but after much trying, I
> can't get it to work.  I tried putting this in my browser/configure.zcml:
>
> <browser:viewlet
>       name="my.product.viewlet"
>       for="my.product.interfaces.IForm"
>       manager="plone.app.layout.viewlets.interfaces.IBelowContentBody"
>       permission="zope2.View"
>       class=".form.Form"
>     />
>
> and I get errors when I try to view the page.  Does anyone know the correct
> way to put a z3c form in a viewlet?

You'll need to wrap the form into a Products.Five.browser.BrowserView.
Overwrite the __call__ method of that to just call the form and return
what it returns.  This is quite similar to how
plone.z3cform.layout.wrap_form works, and in fact, it would be easiest
if you'd write your small wrapper template and pass that as the 'index'
argument to wrap_form.  That template should then probably be included
in plone.z3cform itself.


-- 
Daniel Nouri - http://danielnouri.org





More information about the Product-Developers mailing list