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

Mats Nordgren mats at ronin-group.org
Thu Jun 21 15:03:07 EDT 2007


Thanks Stephan,

I have now got the sub form to render in browser.  Much appreciated.

A few more questions though.  In the create method, the data is only the
parent data.  The self.widgets.extract() returns only parent data.  The only
place I see the sub form data is in self.request.form.  What is the best way
to extract the data and create your object?

Perhaps unrelated but I had this working before. I'm using formui and I'm
getting a "TraversalError: (<ErrorViewSnippet for RequiredMissing>,
'widget')".  I tried to trim out all the sub-form stuff I've messed around
with and replaced a simple object with two textlines one of which is
required.  This happens when I'm submitting the form without an entry in
required field.  With data it works just fine and adds the object.  The
addform is using the macro:form from formui.  Any ideas as to where this
comes from and how I can fix it?

Thanks,

Mats Nordgren

> -----Original Message-----
> From: Stephan Richter [mailto:srichter at cosmos.phy.tufts.edu]
> Sent: Tuesday, June 19, 2007 2:49 PM
> To: zope3-users at zope.org
> Cc: gnosis
> Subject: Re: [Zope3-Users] z3c.form and subforms in an AddForm?
> 
> 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