Cannot get AutocompleteFieldWidgeet to work with a source binder

I did forget that AjaxSelectFieldWidget does not do batching. So once you do a search the result is probably ok, but really you want batching/paging especially if your query string is empty. I actually brought this up awhile back Batching AjaxSelectFieldWidget - #2 by MrTango so batching is supported in select2 but not with the mockup implementation. It really is too bad this doesn't support batching because even if you get the Autocomplete widget to work you are lacking design consistency on forms that mix this and the Ajax select2 implementation.

Side note: https://dist.plone.org/release/5.2.1/versions.cfg pins a version of plone.formwidget.autocomplete that is incompatible with Plone 5. I don't know what repo governs this, or where to report it.

Sorry to revive this old thread. But I am trying fix the issue Can't search and add Relations when adding new content ยท Issue #14 ยท Sinar/popolo.contenttypes ยท GitHub

I tried to monkey patch the 'toWidgetValue' but ended up getting 'from_object' Key error on trying to save the dexterity field (politikus.extractives/extractive_concession.py at 58ee456217c9005c233643b95b5f18303c861dbb ยท Sinar/politikus.extractives ยท GitHub).

    <monkey:patch
      description="Fix z3c.form value error exceptions"
      class="plone.app.z3cform.converters.AjaxSelectWidgetConverter"
      original="toWidgetValue"
      replacement=".converters.toWidgetValue"
      />




# -*- coding: utf-8 -*-
from z3c.form import converter
import six

def toWidgetValue(self, value):
    if not value:
        return self.field.missing_value
    vocabulary = self.widget.get_vocabulary()
    tokenized_value = []
    for term_value in value:
        if vocabulary is not None:
            try:
                term = vocabulary.getTerm(term_value)
                tokenized_value.append(term.token)
                continue
            except (LookupError, ValueError):
                pass
        tokenized_value.append(six.text_type(term_value))
    return getattr(self.widget, 'separator', ';').join(tokenized_value)
KeyError

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 168, in transaction_pubevents
  Module transaction._manager, line 257, in commit
  Module transaction._manager, line 134, in commit
  Module transaction._transaction, line 267, in commit
  Module transaction._transaction, line 333, in _callBeforeCommitHooks
  Module transaction._transaction, line 372, in _call_hooks
  Module Products.CMFCore.indexing, line 316, in before_commit
  Module Products.CMFCore.indexing, line 226, in process
  Module Products.CMFCore.indexing, line 48, in reindex
  Module Products.CMFCore.CatalogTool, line 368, in _reindexObject
  Module Products.CMFPlone.CatalogTool, line 356, in catalog_object
  Module Products.ZCatalog.ZCatalog, line 505, in catalog_object
  Module Products.ZCatalog.Catalog, line 369, in catalogObject
  Module Products.PluginIndexes.unindex, line 242, in index_object
  Module Products.PluginIndexes.unindex, line 287, in _index_object
  Module Products.PluginIndexes.unindex, line 225, in insertForwardIndexEntry
  Module z3c.relationfield.relation, line 89, in __lt__
  Module z3c.relationfield.relation, line 37, in from_path
  Module plone.app.relationfield.monkey, line 19, in get_from_object
KeyError: 'from_object'