[Zope3-Users] Trying to use browser:form -> 404
Garanin Michael
garanin at m-lan.ru
Fri Feb 10 14:10:27 EST 2006
> I've played with zope.formlib before that. I didn't manage to generate a
> entire form, just the <input ...> statemenets were generated, without any
> <html> headers or anything like that. So I need to add them manually with
> python code or a template. Can you tell me how I can generate a form.
> Basically the same like the form directive we're talking about all the time.
>
>
> Thanks,
>
> Florian
It's easy. Example:
1) class IMyForm(Interface):
title = TextLine(...)
2) class MyAddForm(zope.formlib.AddForm):
form_fields = IMyForm
def create(self, data):
# create you object from data-dictionary
class MyEditForm(zope.formlib.EditForm):
form_fields = IMyForm
# yes it's all ! ;-)
3) in browser.zcml
<page
name="AddMyObject.html"
for="zope.app.container.interfaces.IAdding"
class=".MyAddForm"
permission="zope.ManageContent"
/>
<page
name="edit.html"
for=".IMyObjectInterface"
class=".MyEditForm"
permission="zope.ManageContent"
/>
P.S. you can see usage zope.formlib in 'zsqlmap' (my product, see
zope.org ;-)
More information about the Zope3-users
mailing list