[Grok-dev] Re: Multiple addforms with different default values

Jan Ulrich Hasecke janulrich.hasecke at web.de
Mon Jun 2 12:33:01 EDT 2008

Jan Ulrich Hasecke <juhasecke at googlemail.com> writes:

> is it possible to add instances of a model with different default  values via
> addform?
> Perhaps with a exception to grok.AutoFields?

Because nobody answers I try to give more details.

I have one model called animal. But when I add an animal I want to add an
animal of a specific species, say an elephant. And I don't want the user to
fill it out.

Is it possible to have a Addform called AddElephant which hands over some
default values?

Something like this?

        form_fields = grok.AutoFields(IAnimal)
        form_fields['specie'] = 'Elephant'

This does not work. It should render a form where the field 'specie' is filled
with the value 'Elephant'. Perfect would be if fields with default values
cannot be edited.

Any hints?


More information about the Grok-dev mailing list