Question

How can I add multiselect field to a dexterity content type via model xml file? It is clear how to add single selection dropdown field:

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

But how to do multi-select field? Basically the same as I can get with this python (zope schema):

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

There is no problem for me to use python way, I'm just curious how to achieve this with xml.

Thanks,
Rapolas

Was it helpful?

Solution

A value_type tag:

<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>

Your source should implement IContextSourceBinder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top