[Zope3-Users] z3c.form and subforms in an AddForm?

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Jun 19 17:49:16 EDT 2007


On Friday 15 June 2007 13:52, gnosis wrote:
> browser/restaurant.py
>
> class RestaurantAddForm(AddFormLayoutSupport, form.AddForm):
>     """Add form"""
...

You do not need the layout support here, since this view does not render as a 
standalone Web page.

...
>     def update(self):
>         self.address = AddressAddForm(self.context.address, self.request)
> ## <---- Problem area
>         self.address.update()
>         super(RestaurantAddForm, self).update()
...

Simply pass in self.context.

> browser/address.py
...
Looks good.


> browser/configure.zcml
...
>    <!-- Address Add Form -->
>   <z3c:pagelet
>     name="addAddress.html"
>     for="metrod.restaurant.interfaces.IAddress"
>     class=".address.AddressAddForm"
>     layer="metrod.app.layer.IMetroDBrowserLayer"
>     permission="zope.Public" />
...

This directive is not needed, since you never render it as a standalone Web 
page. You already instantiate the view within the person view's update() 
method.

BTW, you forgot the most interesting part. The templates. In the person view 
template you have to somewhere do this or something similar:

<div tal:replace="structure view/address/render" />

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-users mailing list