Hi Jason,
On 15/03/2006, at 3:41, Jason Chu wrote:
> One such form contains something that extends SelectionField. This
> widget
> needs its list of options when it's instantiated (it's possible to
> do it
> later, but you'd have to pass it its own validator...). The list of
> options for the widget is taken from the current user, so we have to
> generate the form at request time, not before. To use this form for
> validation, we pass it to the validate decorator as a class, not an
> instance.
>
You can initialize the form just once and pass the SelectionField a
callable as options which will return fresh options in each display.
This is how I implement something similar in an app Im working on.
def get_options():
return options_for_current_user
TableForm(fields=[
SingleSelectField("lalala", options=get_options),
...
])
Generally, all forms should be instantiated just once so a schema can
be auto-generated for it's fields for later validation (talking SVN
here). That is, the same form instance should handle it's display AND
it's validation.
Alberto
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---