【问题标题】:Plone dexterity multiselect field via model xml file通过模型 xml 文件克隆敏捷多选字段
【发布时间】:2013-07-22 15:47:04
【问题描述】:

如何通过模型 xml 文件将多选字段添加到敏捷内容类型?很清楚如何添加单选下拉字段:

<field name="dummy" type="zope.schema.Choice">
...
<source>plone.supermodel.tests.dummy_binder</source>
</field>

但是如何做多选字段呢?基本上和我用这个 python 得到的一样(zope 模式):

my_field = schema.List(
            title="A title",
            value_type=schema.Choice(source='some.source.vocabulary'),
            required=True
            )

我用python的方式没有问题,我只是好奇怎么用xml来实现。

谢谢,
拉波拉斯

【问题讨论】:

    标签: plone dexterity


    【解决方案1】:

    value_type 标记:

    <field name="links" type="zope.schema.List">
        <title>Related Items</title>
        <value_type type="zope.schema.Choice">
            <title>Related</title>
            <source>plone.supermodel.tests.dummy_binder</source>
        </value_type>
    </field>
    

    您的源应实现 IContextSourceBinder。

    【讨论】:

    • 谢谢,几乎做对了。我的错误是将 指定为标记,而不是属性。
    猜你喜欢
    • 2023-03-23
    • 2012-02-19
    • 1970-01-01
    • 2017-01-11
    • 1970-01-01
    • 2016-05-25
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    相关资源
    最近更新 更多