>
> Hi,
> Thanks for the reply. The form has a SingleSelectField with names
> that come from a database query. It also has a TextField to allow the
> user to enter the name if the desired name isn't already in the
> database/SingleSelectField. So if the user enters a new name in the
> TextField, I would like the SingleSelectField to contain the name they
> just entered after the redirect occurs (don't need to point to it, it
> just needs to one of the selectable names). The SingleSelectField is
> populated in the TableForm class and I can't seem to get the code to
> rerun prior to the redirect. The correct table is being updated, if I
> restart the application the new name shows up in the
> SingleSelectField.
>
> I pasted the code from the TableForm class and the functions for the
> pages here:
> http://paste.turbogears.org/paste/12620
The problem is that you query your datasets while *constructing* the
widget. Which is of course only run once.
What you should do instead is passing callables to your SSFs, like this:
def get_projects():
return [(p.id, p.name) for p in Project.query.all()]
...
SingleSelectField(options=get_projects)
That ensures that the list of actual options is determined on render-time.
Diez
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---