我正在尝试打开一个自定义编辑表单,它只会显示一个包含 12 个字段的表单中的一个字段:
class EditForm(dexterity.EditForm):
grok.name('editCustom')
grok.context(IInfo)
def updateWidgets(self):
super(EditForm, self).updateWidgets()
self.widgets['alps'].mode = 'hidden'
self.widgets['operationStatus'].mode = 'hidden'
# etc.
一切正常,直到我到达一个多字段列表选择的字段:
self.widgets['siteContact'].mode = 'hidden'
(这是 form.Schema 中的条目):
siteContact = schema.List(
title=_(u"Site Contact"),
description =_(u"Select Site Contacts"),
value_type=schema.Choice(vocabulary=("test.siteContact")),
required=False,
)
但是当我尝试访问自定义 EditForm 时,我得到:
Module z3c.form.widget, line 140, in render
Module zope.component._api, line 109, in getMultiAdapter
ComponentLookupError: ((<Container at /test/first>, <HTTPRequest, URL=http://localhost:8080/test/first/@@editCustom>, <Products.Five.metaclass.EditForm object at 0x08F9D9F0>, <zope.schema._field.List object at 0x084844B0>, <OrderedSelectWidget 'form.widgets.siteContact'>), <InterfaceClass zope.pagetemplate.interfaces.IPageTemplate>, 'hidden')