Marius Gedminas shows us how to create a simple add form for Zope3 using formlib, but he then assumes the object in question accepts keywords in the __init__ method. Here's how you can use an additional formlib trick if you don't have such a handy __init__ method:
# This is the mypackage.browser module
from zope.formlib import form
from mypackage.interfaces import IFruit
from mypackage.fruit import Fruit
class FruitAdd(form.AddForm):
form_fields = form.Fields(IFruit)
def create(self, data):
# applyChanges applies all changed fields named in form_fields
# to the object, taking the field values from data.
# In a new object, that's *all* fields.
fruit = Fruit()
form.applyChanges(fruit, self.form_fields, data)
return fruit
applyChanges is also very handy if you use multiple interfaces to build your form_fields variable, e.g. adding IZopeDublinCore fields into the mix. This handy utility method will adapt your object to the correct interface for each and every field to accomplish it's task!