Plone collective.z3cform.datagridfield灵活性和行为

Plone collective.z3cform.datagridfield灵活性和行为,plone,dexterity,z3c.form,Plone,Dexterity,Z3c.form,我正在研究一种敏捷行为,我使用collective.z3cform.datagridfield来实现它 这应该是: +----+-------+----+ | title | value | link | +----+-------+----+ tile = schema.TextLine value = schema.TextLine link = schema.Choice (Related Widget) 这是我的代码: class IDifferentiation

我正在研究一种敏捷行为,我使用collective.z3cform.datagridfield来实现它

这应该是:

+----+-------+----+  
| title | value | link |  
+----+-------+----+  

tile = schema.TextLine  
value = schema.TextLine  
link = schema.Choice (Related Widget)
这是我的代码:

class IDifferentiation(form.Schema):
    title = schema.TextLine(title=_(u'Title for this element', default=u'Title for this element'), required=True)
    value = schema.TextLine(title=_(u'Text for this element', default=u'Text for this element'), required=False)

    form.widget(downloads=RelatedItemsFieldWidget)
    link = schema.Choice(
        title=_(u"Person"),
        source=UUIDSourceBinder(),
        required=True)

class IDifferentiationBox(form.Schema):
    """ """
    form.widget(differentiation=DataGridFieldFactory)
    differentiation = schema.List(
            title=_(u"Differentiation"),
            value_type=DictRow(title=_(u"Facts"), schema=IDifferentiation)
    )

但是对于“link”-字段,我只得到一个Select下拉列表,或者一个In-Out小部件(取决于使用的小部件),没有数据/内容类型可供选择。

我非常确定,您使用的
表单指令
对您的
i区分
界面没有任何作用。因为它不是一个z3c.form,所以它是一个datagrid子表单

但是collective.z3cform.datagridfield添加了一些入口点来修改它的行为

该包通过覆盖添加/编辑表单和视图模板,将不同的小部件添加到特定的datagrid子表单字段

class DataGridEditView(DefaultEditForm):
    """Edit form that uses the ContentTreeWidget for some fields in
    the datagrids.
    """

    def datagridInitialise(self, subform, widget):
        if widget.name == 'form.widgets.differentiation':
            subform.fields['link'].widgetFactory = ContentTreeFieldWidget
首先,您需要注册两个模板,如图所示


因此,这会将
ContentTreeFieldWidget
添加到datagrid子表单字段
链接中

这行中的问题不仅仅是字段名错误吗

form.widget(downloads=RelatedItemsFieldWidget)
宁可

form.widget(link=RelatedItemsFieldWidget)

嗨,我已经试过example.conference了,但它对我和灵巧行为都不起作用。什么不起作用?有追踪吗?example.conference包在没有任何修改的情况下对您有效吗?对不起,没有回溯,什么都没有-只有一个空的选择下拉列表。会议也不起作用我在一次会议上看到了这个例子。但它是为Plone 4.1和DX 1.x构建的。你的包裹是公开的吗?为了提供帮助,最简单的方法是在我的机器上启动/构建您的包。不,抱歉,它不是公开的。我将尝试创建一个自定义构建,以测试-直到周末-我使用plone4.3和dx2
form.widget(link=RelatedItemsFieldWidget)