On Tuesday 15 July 2008, Martin Aspeli wrote:
> It's very common to have a content type that has both an add- and an
> edit form. If you have custom widget setup code and other logic, you
> often have to replicate this across both forms to make them consistent.
> Is there a standard/recommended z3c.form pattern to reduce duplication
> in this case?
Well, there is no framework way, but you can solve it via inheritance.
class ObjectAddForm(ObjectForm, form.AddForm):
class ObjectEditForm(ObjectForm, form.EditForm):
I could also imagine that you could write a base class AddAndEditForm that has
a mode with values ADD and EDIT that switches between the variances.
The difference between an add and edit form are only the button and their
handlers and whether ignoreContext is set to true or false.
Web Software Design, Development and Training
Google me. "Zope Stephan Richter"
Zope3-users mailing list