Last active
September 11, 2015 16:12
-
-
Save vangheem/56cc05c3111683df1537 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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