On Jun 30, 2006, at 2:55 PM, Ulysses Almeida wrote:
>
>> Generally speaking, you reuse the same form object every time. The
>> only reason to do what your original code snippet was doing is if the
>> form itself is going to vary from request to request.
>>
>> Widgets are considered part of the view and don't generally look up
>> stuff in the database directly.
>>
> I agree, but how can I change options on a SingleSelectField on the
> fly? I have a form with a SingleSelectField tha may change option list
> according user state. What's the best way to modify option list on the
> fly without loosing validators error messages?
Pass it a callable that returns fresh options on each request:
def get_options():
return [(art.id, art.name) for art in Article.select()]
sf = SingleSelectField(options=get_options)
HTH,
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---