Set default value in the relatedItems Field

5 views
Skip to first unread message

philippe gross

unread,
Nov 25, 2009, 7:34:41 AM11/25/09
to Dexterity development
Hi!

I would set a default value in the relatedItems Field from the
IRelatedItems Behavior
(plone.app.dexterity.behaviors.related.IRelatedItems).
But i always get an LookupError (Module zope.schema.vocabulary, line
124, in getTerm), when i return a list of strings

Therefore my question, it is possible to add some default value to the
relatedItems Field and how i can do thast what i habe to return in the
default_value function (see below)


@form.default_value(field=IRelatedItems['relatedItems'])
def relatedDefaultValue(data):
paths = data.request.get('paths', None)
if paths:
return path
return

cheers phippu

Martin Aspeli

unread,
Nov 25, 2009, 8:01:58 PM11/25/09
to dexterity-...@googlegroups.com
2009/11/25 philippe gross <gross.p...@gmail.com>:
I'm sure it's possible, but you'll need to return a RelationValue (or
rather, a list thereof), which is what the field actually stores. To
initialise that, you'll need to look up the relevant intids, I think.
Take a look at z3c.relationfield's tests and documentation.

Martin
Reply all
Reply to author
Forward
0 new messages