Google Groups Home
Help | Sign in
Reset for fields
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
GSP  
View profile
 More options Mar 24, 4:26 pm
From: GSP <baycity...@gmail.com>
Date: Mon, 24 Mar 2008 13:26:17 -0700 (PDT)
Local: Mon, Mar 24 2008 4:26 pm
Subject: Reset for fields
This is likely a basic question. When submitting a form, how does one
specify certain fields to be reset upon redirection to the original
page. For example, clearing password and user name fields in a
registration screen?

thanks!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
GSP  
View profile
 More options Mar 25, 10:26 am
From: GSP <baycity...@gmail.com>
Date: Tue, 25 Mar 2008 07:26:33 -0700 (PDT)
Local: Tues, Mar 25 2008 10:26 am
Subject: Re: Reset for fields
Has anyone encountered this issue?

On Mar 24, 4:26 pm, GSP <baycity...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Glauco  
View profile
 More options Mar 25, 10:40 am
From: Glauco <gla...@sferacarta.com>
Date: Tue, 25 Mar 2008 15:40:48 +0100
Local: Tues, Mar 25 2008 10:40 am
Subject: Re: [TurboGears] Reset for fields
GSP ha scritto:

> This is likely a basic question. When submitting a form, how does one
> specify certain fields to be reset upon redirection to the original
> page. For example, clearing password and user name fields in a
> registration screen?

> thanks!

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
GSP  
View profile
 More options Mar 25, 12:13 pm
From: GSP <baycity...@gmail.com>
Date: Tue, 25 Mar 2008 09:13:51 -0700 (PDT)
Local: Tues, Mar 25 2008 12:13 pm
Subject: Re: Reset for fields
I am thinking along the lines of when validation is performed and for
example a password field fails validation.It is preferable to return
to the original form with the password fields cleared. However, it is
not evident to me where and when this could be performed since
validation and redirection is performed deep within a layer of magic.
I am sure there must be an easy way to do this. Coming from a Java
Struts background I am familiar with the reset method of a form to
perform this action, however, it is not apparent how this is done
using TG forms.
On Mar 25, 10:40 am, Glauco <gla...@sferacarta.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Glauco  
View profile
 More options Mar 25, 12:44 pm
From: Glauco <gla...@sferacarta.com>
Date: Tue, 25 Mar 2008 17:44:13 +0100
Local: Tues, Mar 25 2008 12:44 pm
Subject: Re: [TurboGears] Re: Reset for fields
GSP ha scritto:

> I am thinking along the lines of when validation is performed and for
> example a password field fails validation.It is preferable to return
> to the original form with the password fields cleared. However, it is
> not evident to me where and when this could be performed since
> validation and redirection is performed deep within a layer of magic.
> I am sure there must be an easy way to do this. Coming from a Java
> Struts background I am familiar with the reset method of a form to
> perform this action, however, it is not apparent how this is done
> using TG forms.

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

--
+------------------------------------------------------------+
 Glauco Uri  
 glauco(at)sferacarta.com

          Sfera Carta SoftwareŽ       info(at)sferacarta.com
  Via Bazzanese,69  Casalecchio di Reno(BO) - Tel. 051591054
+------------------------------------------------------------+


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Diez B. Roggisch  
View profile
 More options Mar 25, 1:17 pm
From: "Diez B. Roggisch" <de...@web.de>
Date: Tue, 25 Mar 2008 18:17:45 +0100
Local: Tues, Mar 25 2008 1:17 pm
Subject: Re: [TurboGears] Re: Reset for fields
On Tuesday 25 March 2008 17:13:51 GSP wrote:

> I am thinking along the lines of when validation is performed and for
> example a password field fails validation.It is preferable to return
> to the original form with the password fields cleared. However, it is
> not evident to me where and when this could be performed since
> validation and redirection is performed deep within a layer of magic.
> I am sure there must be an easy way to do this. Coming from a Java
> Struts background I am familiar with the reset method of a form to
> perform this action, however, it is not apparent how this is done
> using TG forms.

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
GSP  
View profile
 More options Mar 25, 7:13 pm
From: GSP <baycity...@gmail.com>
Date: Tue, 25 Mar 2008 16:13:11 -0700 (PDT)
Local: Tues, Mar 25 2008 7:13 pm
Subject: Re: Reset for fields
I appreciate everyones response. Unfortutely, I tried each suggestion
but the fields did not reset as expected.
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.

On Mar 25, 1:17 pm, "Diez B. Roggisch" <de...@web.de> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Diez B. Roggisch  
View profile
 More options Mar 26, 5:31 pm
From: "Diez B. Roggisch" <de...@web.de>
Date: Wed, 26 Mar 2008 22:31:48 +0100
Local: Wed, Mar 26 2008 5:31 pm
Subject: Re: [TurboGears] Re: Reset for fields
GSP schrieb:

> I appreciate everyones response. Unfortutely, I tried each suggestion
> but the fields did not reset as expected.

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Diez B. Roggisch  
View profile
 More options Mar 26, 5:48 pm
From: "Diez B. Roggisch" <de...@web.de>
Date: Wed, 26 Mar 2008 22:48:51 +0100
Local: Wed, Mar 26 2008 5:48 pm
Subject: Re: [TurboGears] Re: Reset for fields
Diez B. Roggisch schrieb:

Obviously, replace "text" with whatever name your input-field has.

Diez


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
GSP  
View profile
 More options Mar 26, 6:27 pm
From: GSP <baycity...@gmail.com>
Date: Wed, 26 Mar 2008 15:27:08 -0700 (PDT)
Local: Wed, Mar 26 2008 6:27 pm
Subject: Re: Reset for fields
Ah yes of course, I should have been more specific and referred to the
server side solutions as a server side solution
was my primary goal. I suppose this is a case where the framework
makes the common case uncommonly difficult.
I can't help but think  some type of form reset method would be a
useful extension to the existing form handling mechanism.
Hopefully, this simple goal could be achieved within the context of
whatever magic is happening behind the scenes.
I would be interested to hear opinions on this.

On Mar 26, 5:31 pm, "Diez B. Roggisch" <de...@web.de> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google