[Grok-dev] Re: Multiple addforms with different default values
sebastian at urbantalk.se
Tue Jun 3 04:02:52 EDT 2008
2 jun 2008 kl. 18.33 skrev Jan Ulrich Hasecke:
> Is it possible to have a Addform called AddElephant which hands over
> default values?
> Something like this?
> form_fields = grok.AutoFields(IAnimal)
> form_fields['specie'] = 'Elephant'
This replaces the field 'specie' with the string 'Elephant'. You would
want to put your code in the update method of your addform class. I
suggest that you add a breakpoint in the update method and then
introspect form_fields, I am sure you will find a "default" attribute
of the form_fields['specie'] field object that you can manipulate.
> 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
> cannot be edited.
To make the fields read only (in this case login and role), try
form_fields = grok.Fields(interfaces.IVisitUser,
> Any hints?
More information about the Grok-dev