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

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Jun 22 14:28:22 EDT 2007


On Thursday 21 June 2007 15:03, Mats Nordgren wrote:
> I have now got the sub form to render in browser.  Much appreciated.

Cool.

> 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?

Just access your sub-form. In the new "Address Book"  demo of z3c.formdemo, 
the sub-forms are responsible of creating sub-objects, so there you simply 
can ask for the content like this: form.subForm.getContent(). In edit forms 
you do not have to do anything, because you are modifying thos sub-objects.

Another approach is to ask the widget manager for the data:

form.subform.widgets.extract()

> 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?

No idea. Could you provide the complete traceback?

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