[Grok-dev] Problem with grok.AddForm, grok.Adapter and widgets
Martijn Faassen
faassen at startifact.com
Fri Jan 29 14:54:44 EST 2010
Hannes wrote:
> I've some problem with a schema.Object field when I wanna use grok.AddForm.
>
> Seems like I've to write an Adapter class...?, but unfortunately I don't
> know how.... :-(
>
Hm, it works for edit forms, right? I guess the tricky bit is that you
need objects of the right type to be constructed with an add form. With
an edit form you don't care, you just need to edit the object according
to its schema, whatever object it may be.
I think I've made it work in the past when I *don't* provide a custom
object to create, i.e. I have no Version or Product, but just rely on
the default ObjectWidget to create a default one for me.
Could you show your Version or Product implementation? It looks to me
like these expect multiple arguments to create them. If you changed them
to take no arguments (or created factory functions to do that),
ObjectWidget should be able to create them (call self.factory()).
Looking at the ObjectWidget implementation it should then set the
attributes from your schema directly.
Regards,
Martijn
More information about the Grok-dev
mailing list