ajung wrote:
Hmmm..where do i use a custom vocabulary?
I have no special widget configuration.
Well, you said:
I tried something like
17 class IConversion(form.Schema):$
18 """ Project Folder """$
19 $
20 form.widget(template=RelatedItemsWidget)$
21 template = RelationChoice($
22 title=_(u"Template reference"),$
23
source=ObjPathSourceBinder(object_provides=IAuthoringTemplate.__identifier__),$
24 required=False,$
25 )$
ObjPathSourcebinder is for the old plone.formwidget.contenttree-widget
and probably does not work with p.a.widget's RelatedItemsFieldWidget. I
don't even know if p.a.widgets is expect to work with "sources" yet.
Yet, you can use it with a custom vocabulary (and base your vocabulary
on CatalogVocabularyFactory by forcing wanted portal_types for its
query):
https://github.com/plone/plone.app.vocabularies/blob/master/plone/app/vocabularies/catalog.py#L492
Maybe it's even possible to create configurable sourcebinder from that,
but I haven't tried it.
If this seems to require more work than expected, maybe it's that this
is supposed to be ready only for Plone 5 :)
-Asko
Asko Soukka wrote
Hi,
it's not that easy with a custom source/vocabulary yet :(
Pointers:
1. Setting vocabulary in schema (though, there was a custom
"ajax_vocabulary"-attribute instead of "vocabulary"-attribute still in
p.a.widgets 1.3.2):
https://github.com/plone/plone.app.widgets/blob/master/plone/app/widgets/dx_bbb.py#L71
2. Vocabulary access requires defining a permission:
https://github.com/plone/plone.app.widgets/blob/master/plone/app/widgets/browser/vocabulary.py#L16
(We needed to inject permission for our custom vocabulary there to
make it work.)
3. Vocabulary call should accept query-parameter:
https://github.com/plone/plone.app.vocabularies/blob/master/plone/app/vocabularies/catalog.py#L495
-Asko
ajung wrote:
ok, the widget now shows up. However nothing is found - neither through
the
browser nor through the search tab. I see that the JSON requests to
@@getVocabulary but always zero results...digging depper now..
-aj
Asko Soukka wrote
Hi,
you should use RelatedItemsFieldWidget instead of RelatedItemsWidget
(the same naming convention applies for all z3c.form-widgets).
Regards,
Asko
Andreas Jung wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi there,
I am trying to get the RelatedItemsWidget of plone.app.widgets
flying with a Dexterity 2 content-type.
I tried something like
17 class IConversion(form.Schema):$
18 """ Project Folder """$
19 $
20 form.widget(template=RelatedItemsWidget)$
21 template = RelationChoice($
22 title=_(u"Template reference"),$
23
source=ObjPathSourceBinder(object_provides=IAuthoringTemplate.__identifier__),$
24 required=False,$
25 )$
but this gives me
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.z3cform.layout, line 66, in __call__
Module plone.z3cform.layout, line 50, in update
Module plone.dexterity.browser.add, line 112, in update
Module plone.z3cform.fieldsets.extensible, line 59, in update
Module plone.z3cform.patch, line 30, in GroupForm_update
Module z3c.form.group, line 128, in update
Module z3c.form.form, line 134, in updateWidgets
Module z3c.form.field, line 254, in update
TypeError: __init__() takes exactly 2 arguments (3 given)
_______________________________________________
Product-Developers mailing list
product-develop...@lists.plone.org
https://lists.plone.org/mailman/listinfo/plone-product-developers