[Grok-dev] Re: Multiple addforms with different default values
janwijbrand at gmail.com
Tue Jun 3 04:50:33 EDT 2008
Jan Ulrich Hasecke wrote:
> Jan Ulrich Hasecke <juhasecke at googlemail.com> writes:
>> is it possible to add instances of a model with different default values via
>> 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'
I think you could do:
form_fields['specie'].get_rendered = lambda x: 'Elephant'
This will pre-populate the field with the "Elephant" value.
Hope this helps.
More information about the Grok-dev