is a strange issue...
but anyway your web form is inside TG a simple dict() so you can do
anywere before rendering of the page:
for fi in ['field1','field2']
data[ fi ] = None
turbogears.redirect( bla bla bla, **data )
Have i understood right?
Gla
--
+------------------------------------------------------------+
Glauco Uri
glauco(at)sferacarta.com
Sfera Carta SoftwareŽ info(at)sferacarta.com
Via Bazzanese,69 Casalecchio di Reno(BO) - Tel. 051591054
+------------------------------------------------------------+
Ahh ok , probably i've understood now :-)
def your_controller(self,tg_errors=None, **data):
if tg_errors:
# I want to RESET hardly these fields in all case of error
data['my_field1_to_reset'] = None
data['my_field2_to_reset'] = None
Glauco
Besides that I never understood the reason a password-field is cleared in such
cases & find it an annoyance (it is *NOT* security, just a false sense of),
you have two options here:
- use Javascript (easy, but not so nice)
- you need to clear the cherrypy.request parameters for the passsword-fields.
I'm not totally sure out of my head how to do so - but either
del cherrypy.request.password
cherrypy.request.password = None
or such should do the trick.
Diez
You certainly didn't try every suggestion - Javascript would have helped.
> I did try instantiating the form in the controller method and this
> achieves the goal of resetting the fields, however, data used to
> identify if a field is in
> error is discarded. Obviously, this is not a good solution. I wonder
> if any of the project developers could offer a hint. Surely this is
> not an uncommon use case.
Matter of factly I am one of the developers. But I have to admit that
this is one of the darker black magic corners of turbogears that is hard
to grasp. I had to dig deep to find what's happening, and I'm actually
not sure how everything works - but I managed to solve the issue.
My basic suggestion of manipulating the request was right - but not the
actual key/name used.
Try this:
if hasattr(request, "input_values") and 'text' in request.input_values:
del request.input_values['text']
Diez
Obviously, replace "text" with whatever name your input-field has.
Diez