Skip to content

Instantly share code, notes, and snippets.

@vangheem
Last active September 11, 2015 16:12
Show Gist options
  • Save vangheem/56cc05c3111683df1537 to your computer and use it in GitHub Desktop.
Save vangheem/56cc05c3111683df1537 to your computer and use it in GitHub Desktop.
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