Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plone dexterity multiselect field via model xml file

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

like image 822
Rapolas K. Avatar asked Oct 15 '25 08:10

Rapolas K.


1 Answers

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.

like image 91
SteveM Avatar answered Oct 18 '25 03:10

SteveM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!