On Tuesday 12 June 2007 11:45, Hermann Himmelbauer wrote:
> I've read the doctests of z3c.forms and have to say that the package is
> really impressive. Many things look a lot cleaner and more customizeable
> than formlib. Thanks!
> However, what I don't know is how to read/write values of multiple widgets
> into one context attribute. A common example of this would be a date, which
> is represented by three TextWidgets (rendered as input fields) that hold
> the year, month and day, which is stored into one context attribute of type
> What would be the best way to accomplish that?
This is the easy case. You should write a special widget that simply renders
three HTML input tags.
> The reverse seems to be possible, e.g. a datamanger that splits a widget
> value into chunks, which are then stored into seperate context attributes,
> e.g. via a datamanger like "context.user, context.host =
> '[EMAIL PROTECTED]'.split('@')".
This is actually the tricky case. The datamanager will not work here, because
it is registered for one field-widget pair. I just discussed this with Roger
a bit, and I agree with his opinion that one widget can only write to one
field. So the solution lies in your content component:
user = ''
host = ''
return self.user + '@' + self.host
def set(self, value):
self.user, self.host = value.split('@')
return property(get, set)
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
Zope3-users mailing list