On 26/02/14 21:28, ajung wrote:
I have a custom Dexterity type with a RelationField
54 media = RelationChoice($
55 title=_(u"label_podcast_item_media"),$
56 description=_(u"help_podcast_item_media"),$
57
source=ObjPathSourceBinder(object_provides=IMediaItem.__identifier__),$
58 required=False,$
59 ) $
that should make use of the plone.app.widgets's widget of the related items
field.
I was reading through dx.py and dx_bbb.py but I don't get the point how to
reuse
the existing widget here. Any pointer?
FWIW, this is what I'm using in a recent project:
form.widget(
location_ref='plone.formwidget.contenttree.ContentTreeFieldWidget')
location_ref = schema.Choice(
title=_(
u"label_plandate_location",
default=u"Location"),
description=_(
u"help_plandate_location",
default=(u"If this event is not at your profile location, "
u"choose a different location.")),
source=UUIDSourceBinder(
object_provides=IReferenceableLocation.__identifier__),
required=False
)
And then this is the getter logic:
def _get_location(self):
if not self.location_ref:
return None
location = uuidToObject(self.location_ref)
if not location:
log.warn("Removing invalid location_ref %s from %s" % (
self.location_ref, repr(self)))
self.location_ref = None
return None
assert IReferenceableLocation.providedBy(location)
return location
This will give you a nice ajaxified UX.
:*CU#
--
Guido Stevens | +31.43.3618933 | http://cosent.nl
s o c i a l k n o w l e d g e t e c h n o l o g y
_______________________________________________
Product-Developers mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/plone-product-developers