On Nov 16, 6:02 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> 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
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
Thanks,
Eric
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---