Skip to content

Instantly share code, notes, and snippets.

@vangheem
Last active Sep 11, 2015
Embed
What would you like to do?
import zope.interface
import zope.schema.interfaces
import z3c.form.interfaces
import z3c.form.browser.textarea
import z3c.form.widget
from plone.app.z3cform.widget import RelatedItemsWidget
class MyRelatedItemsWidget(RelatedItemsWidget):
def _base_args(self):
args = super(MyRelatedItemsWidget, self)._base_args()
args['pattern_options']['selectableTypes'] = ['SomeType']
args['pattern_options']['baseCriteria'] = [{
'i': 'portal_type',
'o': 'plone.app.querystring.operation.list.contains',
'v': ['SomeType', 'Folder']
}]
return args
@zope.component.adapter(zope.schema.interfaces.IField,
IMyLayer)
@zope.interface.implementer(z3c.form.interfaces.IFieldWidget)
def MyRelatedItemFieldWidget(field, request):
widget = z3c.form.widget.FieldWidget(field,
MyRelatedItemsWidget(request))
widget.vocabulary = 'plone.app.vocabularies.Catalog'
return widget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment