On Friday 14 November 2008 08:58:05 Eric wrote:
> Hi,
> Using TG 1.9.7a4, TG rookie. After submitting a form, I redirect back
> to the same page to allow another entry.
>
> raise redirect("new_ai")
>
> There are SingleSelectField widgets whose values could change as a
> result of the previous submission.  What is the best way to force the
> SingleSelectFields to reload?
>
>     def new_ai(self, **kw):
>         """Form to add new record"""
>         pylons.c.form = create_aitracker_form
>         return dict(modelname='Action Item')
>
> The TableForm class for the page has these lines:
>
> people = DBSession.query(Person.id, Person.fullname).order_by
> (Person.fullname).all()
> assigned_by_id = SingleSelectField("Person_by", options = people,
> default = 0, label_text = "Assigned by")
>

I'm not entirely sure what you are after here. Do you want the 
SingleSelectField to be pointing to the value the user selected before 
submitting the form?

Then don't use redirect. Redirect forces the browser to load the page from 
scratch - so how should TG know what value to select?

Instead, use the @validate-decorator with the form, and a proper error_handler 
that re-displays the form. It will then automatically get the user-filled-in 
values.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to