[Zope3-Users] formlib problem
Jim Washington
jwashin at vt.edu
Wed Apr 19 12:10:35 EDT 2006
Stéphane Brault wrote:
> Hi Jim,
> the Items object is my object, linked to my items, table which implements the IItems interface I use for my form:
>
> from neteven.interfaces.items import IItems
> from zope.formlib import form
>
> class ItemsForm(form.EditForm):
> form_fields = form.Fields(IItems)
> form_fields = form_fields.omit('dateLastUpdate')
>
> Items is defined this way:
>
> from zope.interface import implements
> from sqlobject import *
> from sqlos import SQLOS
> from neteven.interfaces.items import IItems
>
> class Items(SQLOS):
> implements(IItems)
>
> class sqlmeta:
> table = 'items'
> ....
>
> When I add this zcml declaration :
> <browser:page
> for=".interfaces.items.IItems"
> name="edit.html"
> class=".forms.items.ItemsForm"
> menu="zmi_views"
> title="Edit a Item"
> permission="zope.ManageContent"
> />
> everything works fine from the ZMI (I created simple containers to test that).
>
> My JSON server side code is:
>
> def getItemEdit(self, itemId):
> item = Items.get(itemId) #a sqlos function to get an Item instance from the table given its Id
> return ItemsForm(item, self.request)()
>
> The fact is I don't use any page template right now ( though I might do this later to have a nice GUI).
>
>
Actually, you are using a page template.
Calling ItemsForm() invokes the render() method of
zope.formlib.form.FormBase, which uses pageform.pt in the zope.formlib
folder by default. This is where title_or_id is requested.
You may wish to set a different template for your ItemsForm class.
Have you tried subclassing form.SubPageEditForm instead of form.EditForm?
-Jim Washington
More information about the Zope3-users
mailing list