[Zope-CMF] zc.formlib and content types

Charlie Clark charlie at begeistert.org
Mon Jan 26 11:11:05 EST 2009

Am 26.01.2009 um 15:41 schrieb Miles:

> Hi,
> I've been playing with zc.formlib and five to create some simple  
> content
> types - not exactly ahead of the curve, I know!
> I want to create a multipage "wizard"-type form.  Each page shares a  
> lot
> of logic, so at the moment I have one view class, and register  
> different
>   templates against it for the various changes.  However, with  
> formlib,
> I can't see how I'd do this.  Is there a more elegant solution than  
> just
> creating 3 separate forms?

Hiya Miles,

are you playing with formlib or zc3.form? Formlib lets you override  
templates pretty easily by redefining the template attribute for each  
view (please don't rely on the following paths!):

class PageOne(CMFDefault.formlib.form.PageForm):
	"""class with most of the logic"""

	template = "templates/first_template.pt"

class PageTwo(PageOne):

	"""logic stays the same but the template has to be different"""

	template = "templates/second_template.pt"

class PageThree(PageOne):
	template = "templates/second_template.pt"

NB. this assumes that your form templates share the same macro for  
rendering the actual widgets and should be used when you really need  
different templates.

Charlie Clark
Helmholtzstr. 20
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226

More information about the Zope-CMF mailing list