RelationList with CatalogSource in 5.1

In 5.0 I had a field like this

client_contacts = RelationList(
        title=_(u'Client contacts'),
        default=[],
        required=False,
        value_type=RelationChoice(title=_(u'Contact'),
                                  source=CatalogSource(object_provides='ims.contacts.interfaces.IContact'), ),
    )

In 5.1.5 it appears to search in the current context with a depth of 1. Really I don't want the user to be navigating at all, I just want a drop down list where in the backend it creates actual references.

Looking at the request query, the criteria contains "criteria": [{"i":"path","o":"plone.app.querystring.operation.string.path","v":"/my/site/::1"}]. Testing in 5.0, the value of "criteria" is an emtpy list. Is there a way to specify no path here? I'm not entirely sure why I'm getting different behavior between 5.0 and 5.1 although obviously the related items widget changed.

I really want to be doing what is described here https://docs.plone.org/external/plone.app.dexterity/docs/advanced/references.html except that there are some problems with doing this. It is not clear why I need to use ObjPathSourceBinder from plone.formwidget.contenttree instead of CatalogSource. plone.formwidget.contenttree is not part of Plone core in 5.1. Adding it and using ObjPathSourceBinder has the same result though, likely because it's the same widget - it's only searching for provided interface within the current context and I want it to be context agnostic.

I've tried to use the AjaxSelectFieldWidget or SelectFieldWidget from plone.app.z3cform which seems like it would be more appropriate, except I don't know how to get it to work with CatalogSource and references in general.

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module plone.app.content.browser.vocabulary, line 258, in __call__
AttributeError: 'RequestContainer' object has no attribute 'value'

Using the default RelatedItemsFieldWidget isn't ideal but would be fine if I could get it to ignore path completely. This was what I was doing in 5.0, with some css to hide the breadcrumb section. I've tried some different pattern_options but this doesn't seem to be possible anymore

I think what I want is to configure the pattern_options for the widget as such

directives.widget(
        'client_contacts',
        RelatedItemsFieldWidget,
        pattern_options={
            'mode': 'search'
        }
    )

I think is the right approach? The docs do not appear to be up to date, maybe it should mention something about the changes to the related item pattern in 5.1 and available options. I'd be interested in helping there but not feel fully qualified.

From: https://github.com/plone/mockup/blob/master/mockup/patterns/relateditems/pattern.js#L13

mode(string): Initial widget mode. Possible values: are 'auto', 'search' and 'browse'. If set to 'search', the catalog is searched for a searchterm. If set to 'browse', browsing starts at basePath. Default: 'auto', which means the combination of both.

Some weeks ago, I stumbled on not being able to use a catalog source while adapting a product for 5.2 - ended up using a named vocabulary

I had a similar problem a few weeks ago and the documentation did not really help. Apart from the fact that much under Plone 5.1.5 did not work.
I tried to set the basepath to root instead of context and ended up like this:

cover = RelationChoice(
    title=_(u'label_cover'),
    required=False,
    vocabulary='plone.app.vocabularies.Catalog',
)
directives.widget(
    'cover',
    RelatedItemsFieldWidget,
    pattern_options={
        'selectableTypes': ['Image'],
        'basePath': '/',
        'favorites': []
    },
)

It was quite a bit tricky to get there. I fully agree that the documentation should be updated here.

(For reference)
For RelationList, I think this should work with 5.1.5

relatedItems = RelationList(
    title=_(u'label_related_items', default=u'Something'),
    default=[],
    value_type=RelationChoice(
        title=u'Related stuff',
        source=CatalogSource(portal_type=['project', 'Image']),
    ),
    required=False,
)

directives.widget(
    'relatedItems',
    RelatedItemsFieldWidget,
    pattern_options={
        'basePath': '/',
        "mode": "auto",
        "favorites": []
        }
    )

I was able to get phil31's example to work but having to use pattern options for selectable type loses some of the richness available in searching by interface. It also means it's not passing through server side validation, and while client side abuse is probably unlikely, it does also mean that you can't use this schema in other places programmatically and enforce those content types.

I was not able to get espenmn's example to work, it had the same problem where I couldn't browse through folderish items to get to my selectable types. Search mode seems more relevant to my particular use case.

Interestingly, the documentation in pattern.js for that mockup pattern doesn't even mention "auto" as an option for mode.

mode(string): Initial widget mode. Possible values: 'search', 'browse'. If set to 'search', the catalog is searched for a searchterm. If set to 'browse', browsing starts at basePath. Default: 'search'.

That's not true though, the default appears to be "auto". I'm not clear on what exactly auto is supposed to do.

Plone Foundation Code of Conduct