on plone 5.2 i have a custom content-type with a shema on the filesystem.
I want to get the widget for a plone.app.vocabularies.catalog.CatalogSource based Choice-Field working. It displays a loading error. Maybe i am missing some widget-parameter in the shema definition, but cannot find any documentation about setting it.
There are examples on setting widget parameters on a RelationCoice-fields. But which of them if any can be used or which are needed for a ChoiceField with a select2-widget ?
Maybe it's wrong that a select2-widget is the default for a CatalogSource-based Coice-Field and i should use a simple dropdown like in the level1-field ?
I thought I remembered having used a CatalogSource to achieve what you want (Plone 5.2). As it turns out, I eventually gave up and came up with a solution similar to @1letter did above:
related_slider_banners = RelationList(
title=_(u'Slider Banners'),
description=_(u'These banners will be used in the slider'),
default=[],
value_type=RelationChoice(
title=_(u'Target'),
#source=CatalogSource(banner_has_image=True),
vocabulary='plone.app.vocabularies.Catalog',
),
required=False,
)
directives.widget(
'related_slider_banners',
RelatedItemsFieldWidget,
pattern_options={
'recentlyUsed': True,
'basePath': '/',
'mode': 'auto',
'favorites': get_favorites,
'folderTypes': ['Folder', 'LIF', 'LRF'],
'selectableTypes' : ['dry_banner'],
}
)
The pattern options allow you to define functions that return custom values.
There's also effort going on in refactoring the pat-relateditems pattern to a "miller column browser" like file browser (kudos to @MrTango) so hopefully with this update we get rid of the currently patched and ancient select2==3.5.4 version and can update select2 to the latest version... or even better -> get rid of select2 in favor of another fancy pancy select field JS library