librelist archives

« back to archive

How can I override request.form values

How can I override request.form values

From:
Guy Jacks
Date:
2013-09-10 @ 16:49
Hi All,

I have rare requirement in which I need to override the request.form
key,value pairs before displaying the form.  Can anyone show me how to do
this?

The flow is that the user submits the form with data and then I redisplay
the form to the user with the values she entered.  The challenge is that I
need to change the names of the form fields before redisplaying the form.

Thank you,

Guy Jacks

Re: [flask] How can I override request.form values

From:
Ryan O'Donnell
Date:
2013-09-10 @ 18:40
Are you using WTForms?


On Tue, Sep 10, 2013 at 12:49 PM, Guy Jacks <guy.jacks@gmail.com> wrote:

> Hi All,
>
> I have rare requirement in which I need to override the request.form
> key,value pairs before displaying the form.  Can anyone show me how to do
> this?
>
> The flow is that the user submits the form with data and then I redisplay
> the form to the user with the values she entered.  The challenge is that I
> need to change the names of the form fields before redisplaying the form.
>
> Thank you,
>
> Guy Jacks
>

Re: [flask] How can I override request.form values

From:
Guy Jacks
Date:
2013-09-10 @ 18:56
Yes I am.


On Tue, Sep 10, 2013 at 2:40 PM, Ryan O'Donnell <odonnellryanc@gmail.com>wrote:

> Are you using WTForms?
>
>
> On Tue, Sep 10, 2013 at 12:49 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>
>> Hi All,
>>
>> I have rare requirement in which I need to override the request.form
>> key,value pairs before displaying the form.  Can anyone show me how to do
>> this?
>>
>> The flow is that the user submits the form with data and then I redisplay
>> the form to the user with the values she entered.  The challenge is that I
>> need to change the names of the form fields before redisplaying the form.
>>
>> Thank you,
>>
>> Guy Jacks
>>
>
>


-- 
Internet Strategist and Applications Architect

mobile: 614.448.7649
guy.jacks@gmail.com
gtalk: guy.jacks
skype: guy.jacks

Re: [flask] How can I override request.form values

From:
Slater Victoroff
Date:
2013-09-10 @ 19:27
If you know how the forms are identified in css you can change this with a
small jQuery script. Something like:

$("#form-field").eq(0).attr("name", "newName");


On Tue, Sep 10, 2013 at 2:56 PM, Guy Jacks <guy.jacks@gmail.com> wrote:

> Yes I am.
>
>
> On Tue, Sep 10, 2013 at 2:40 PM, Ryan O'Donnell <odonnellryanc@gmail.com>wrote:
>
>> Are you using WTForms?
>>
>>
>> On Tue, Sep 10, 2013 at 12:49 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>>
>>> Hi All,
>>>
>>> I have rare requirement in which I need to override the request.form
>>> key,value pairs before displaying the form.  Can anyone show me how to do
>>> this?
>>>
>>> The flow is that the user submits the form with data and then I
>>> redisplay the form to the user with the values she entered.  The challenge
>>> is that I need to change the names of the form fields before redisplaying
>>> the form.
>>>
>>> Thank you,
>>>
>>> Guy Jacks
>>>
>>
>>
>
>
> --
> Internet Strategist and Applications Architect
>
> mobile: 614.448.7649
> guy.jacks@gmail.com
> gtalk: guy.jacks
> skype: guy.jacks
>

Re: [flask] How can I override request.form values

From:
Guy Jacks
Date:
2013-09-10 @ 19:40
Good idea Slater.  I didn't think of that.  I may have to resort to that if
I can't find a way to do it server side.  Thanks for sharing.


On Tue, Sep 10, 2013 at 3:27 PM, Slater Victoroff <
slater.r.victoroff@gmail.com> wrote:

> If you know how the forms are identified in css you can change this with a
> small jQuery script. Something like:
>
> $("#form-field").eq(0).attr("name", "newName");
>
>
> On Tue, Sep 10, 2013 at 2:56 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>
>> Yes I am.
>>
>>
>> On Tue, Sep 10, 2013 at 2:40 PM, Ryan O'Donnell <odonnellryanc@gmail.com>wrote:
>>
>>> Are you using WTForms?
>>>
>>>
>>> On Tue, Sep 10, 2013 at 12:49 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>>>
>>>> Hi All,
>>>>
>>>> I have rare requirement in which I need to override the request.form
>>>> key,value pairs before displaying the form.  Can anyone show me how to do
>>>> this?
>>>>
>>>> The flow is that the user submits the form with data and then I
>>>> redisplay the form to the user with the values she entered.  The challenge
>>>> is that I need to change the names of the form fields before redisplaying
>>>> the form.
>>>>
>>>> Thank you,
>>>>
>>>> Guy Jacks
>>>>
>>>
>>>
>>
>>
>> --
>> Internet Strategist and Applications Architect
>>
>> mobile: 614.448.7649
>> guy.jacks@gmail.com
>> gtalk: guy.jacks
>> skype: guy.jacks
>>
>
>


-- 
Internet Strategist and Applications Architect

mobile: 614.448.7649
guy.jacks@gmail.com
gtalk: guy.jacks
skype: guy.jacks

Re: [flask] How can I override request.form values

From:
Ryan O'Donnell
Date:
2013-09-10 @ 19:58
This came up earlier: Just change form.fieldname.data to the value you'd
like to have displayed. Does that answer your question or am I
misunderstanding?


On Tue, Sep 10, 2013 at 3:40 PM, Guy Jacks <guy.jacks@gmail.com> wrote:

> Good idea Slater.  I didn't think of that.  I may have to resort to that
> if I can't find a way to do it server side.  Thanks for sharing.
>
>
> On Tue, Sep 10, 2013 at 3:27 PM, Slater Victoroff <
> slater.r.victoroff@gmail.com> wrote:
>
>> If you know how the forms are identified in css you can change this with
>> a small jQuery script. Something like:
>>
>> $("#form-field").eq(0).attr("name", "newName");
>>
>>
>> On Tue, Sep 10, 2013 at 2:56 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>>
>>> Yes I am.
>>>
>>>
>>> On Tue, Sep 10, 2013 at 2:40 PM, Ryan O'Donnell <odonnellryanc@gmail.com
>>> > wrote:
>>>
>>>> Are you using WTForms?
>>>>
>>>>
>>>> On Tue, Sep 10, 2013 at 12:49 PM, Guy Jacks <guy.jacks@gmail.com>wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> I have rare requirement in which I need to override the request.form
>>>>> key,value pairs before displaying the form.  Can anyone show me how to do
>>>>> this?
>>>>>
>>>>> The flow is that the user submits the form with data and then I
>>>>> redisplay the form to the user with the values she entered.  The challenge
>>>>> is that I need to change the names of the form fields before redisplaying
>>>>> the form.
>>>>>
>>>>> Thank you,
>>>>>
>>>>> Guy Jacks
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Internet Strategist and Applications Architect
>>>
>>> mobile: 614.448.7649
>>> guy.jacks@gmail.com
>>> gtalk: guy.jacks
>>> skype: guy.jacks
>>>
>>
>>
>
>
> --
> Internet Strategist and Applications Architect
>
> mobile: 614.448.7649
> guy.jacks@gmail.com
> gtalk: guy.jacks
> skype: guy.jacks
>

Re: [flask] How can I override request.form values

From:
Guy Jacks
Date:
2013-09-10 @ 20:27
I actually need to change the fieldname key, not the value.  Here is what
I'm trying to do:

1st time form is displayed:

<textarea name="question-1"></textarea> <!-- this is a question that the
user has not answered before -->
<textarea name="answer-32-question-2">Previous answer text</textarea><!--
this is a question that the user has answered before -->

The user fills in an answer to question 1 and submits the form:

I save the users answers to each question and redisplay the form.  I can't
use the name "question-1" for the fieldname anymore though.  I need to the
form to redisplay like this:

<textarea name="*answer-53-question-1*"></textarea> <!-- now question 1 has
been answered before-->
<textarea name="answer-32-question-2">Previous answer text</textarea><!--
this is a question that the user has answered before -->

I posted a longer explanation a couple days ago that I think scared
everyone off!:
http://librelist.com/browser//flask/2013/9/8/create-a-multidict-in-flask/


On Tue, Sep 10, 2013 at 3:58 PM, Ryan O'Donnell <odonnellryanc@gmail.com>wrote:

> This came up earlier: Just change form.fieldname.data to the value you'd
> like to have displayed. Does that answer your question or am I
> misunderstanding?
>
>
> On Tue, Sep 10, 2013 at 3:40 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>
>> Good idea Slater.  I didn't think of that.  I may have to resort to that
>> if I can't find a way to do it server side.  Thanks for sharing.
>>
>>
>> On Tue, Sep 10, 2013 at 3:27 PM, Slater Victoroff <
>> slater.r.victoroff@gmail.com> wrote:
>>
>>> If you know how the forms are identified in css you can change this with
>>> a small jQuery script. Something like:
>>>
>>> $("#form-field").eq(0).attr("name", "newName");
>>>
>>>
>>> On Tue, Sep 10, 2013 at 2:56 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>>>
>>>> Yes I am.
>>>>
>>>>
>>>> On Tue, Sep 10, 2013 at 2:40 PM, Ryan O'Donnell <
>>>> odonnellryanc@gmail.com> wrote:
>>>>
>>>>> Are you using WTForms?
>>>>>
>>>>>
>>>>> On Tue, Sep 10, 2013 at 12:49 PM, Guy Jacks <guy.jacks@gmail.com>wrote:
>>>>>
>>>>>> Hi All,
>>>>>>
>>>>>> I have rare requirement in which I need to override the request.form
>>>>>> key,value pairs before displaying the form.  Can anyone show me how to do
>>>>>> this?
>>>>>>
>>>>>> The flow is that the user submits the form with data and then I
>>>>>> redisplay the form to the user with the values she entered.  The challenge
>>>>>> is that I need to change the names of the form fields before redisplaying
>>>>>> the form.
>>>>>>
>>>>>> Thank you,
>>>>>>
>>>>>> Guy Jacks
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Internet Strategist and Applications Architect
>>>>
>>>> mobile: 614.448.7649
>>>> guy.jacks@gmail.com
>>>> gtalk: guy.jacks
>>>> skype: guy.jacks
>>>>
>>>
>>>
>>
>>
>> --
>> Internet Strategist and Applications Architect
>>
>> mobile: 614.448.7649
>> guy.jacks@gmail.com
>> gtalk: guy.jacks
>> skype: guy.jacks
>>
>
>


-- 
Internet Strategist and Applications Architect

mobile: 614.448.7649
guy.jacks@gmail.com
gtalk: guy.jacks
skype: guy.jacks

Re: [flask] How can I override request.form values

From:
Franklyn Tackitt
Date:
2013-09-10 @ 20:40
You may be able to edit the form.question.name attribute, but I havent
tested this myself


On Tue, Sep 10, 2013 at 1:27 PM, Guy Jacks <guy.jacks@gmail.com> wrote:

> I actually need to change the fieldname key, not the value.  Here is what
> I'm trying to do:
>
> 1st time form is displayed:
>
> <textarea name="question-1"></textarea> <!-- this is a question that the
> user has not answered before -->
> <textarea name="answer-32-question-2">Previous answer text</textarea><!--
> this is a question that the user has answered before -->
>
> The user fills in an answer to question 1 and submits the form:
>
> I save the users answers to each question and redisplay the form.  I can't
> use the name "question-1" for the fieldname anymore though.  I need to the
> form to redisplay like this:
>
> <textarea name="*answer-53-question-1*"></textarea> <!-- now question 1
> has been answered before-->
> <textarea name="answer-32-question-2">Previous answer text</textarea><!--
> this is a question that the user has answered before -->
>
> I posted a longer explanation a couple days ago that I think scared
> everyone off!:
> http://librelist.com/browser//flask/2013/9/8/create-a-multidict-in-flask/
>
>
> On Tue, Sep 10, 2013 at 3:58 PM, Ryan O'Donnell <odonnellryanc@gmail.com>wrote:
>
>> This came up earlier: Just change form.fieldname.data to the value you'd
>> like to have displayed. Does that answer your question or am I
>> misunderstanding?
>>
>>
>> On Tue, Sep 10, 2013 at 3:40 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>>
>>> Good idea Slater.  I didn't think of that.  I may have to resort to that
>>> if I can't find a way to do it server side.  Thanks for sharing.
>>>
>>>
>>> On Tue, Sep 10, 2013 at 3:27 PM, Slater Victoroff <
>>> slater.r.victoroff@gmail.com> wrote:
>>>
>>>> If you know how the forms are identified in css you can change this
>>>> with a small jQuery script. Something like:
>>>>
>>>> $("#form-field").eq(0).attr("name", "newName");
>>>>
>>>>
>>>> On Tue, Sep 10, 2013 at 2:56 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>>>>
>>>>> Yes I am.
>>>>>
>>>>>
>>>>> On Tue, Sep 10, 2013 at 2:40 PM, Ryan O'Donnell <
>>>>> odonnellryanc@gmail.com> wrote:
>>>>>
>>>>>> Are you using WTForms?
>>>>>>
>>>>>>
>>>>>> On Tue, Sep 10, 2013 at 12:49 PM, Guy Jacks <guy.jacks@gmail.com>wrote:
>>>>>>
>>>>>>> Hi All,
>>>>>>>
>>>>>>> I have rare requirement in which I need to override the request.form
>>>>>>> key,value pairs before displaying the form.  Can anyone show me how to do
>>>>>>> this?
>>>>>>>
>>>>>>> The flow is that the user submits the form with data and then I
>>>>>>> redisplay the form to the user with the values she entered.  The challenge
>>>>>>> is that I need to change the names of the form fields before redisplaying
>>>>>>> the form.
>>>>>>>
>>>>>>> Thank you,
>>>>>>>
>>>>>>> Guy Jacks
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Internet Strategist and Applications Architect
>>>>>
>>>>> mobile: 614.448.7649
>>>>> guy.jacks@gmail.com
>>>>> gtalk: guy.jacks
>>>>> skype: guy.jacks
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Internet Strategist and Applications Architect
>>>
>>> mobile: 614.448.7649
>>> guy.jacks@gmail.com
>>> gtalk: guy.jacks
>>> skype: guy.jacks
>>>
>>
>>
>
>
> --
> Internet Strategist and Applications Architect
>
> mobile: 614.448.7649
> guy.jacks@gmail.com
> gtalk: guy.jacks
> skype: guy.jacks
>

Re: [flask] How can I override request.form values

From:
Guy Jacks
Date:
2013-09-12 @ 01:06
Hi All,

Thanks for the help.  My question was answered in the other thread I
started.  I'll paste it here for future archival purposes.

I was able to import the MultiDict from Werkzeug as follows:

from werkzeug import MultiDict

I then simply created the MultiDict and passed it to form like:

md = MultiDict()
md.add(...)
md.add(...)
form = UserForm(md, ...)

Franklyn, I'm going to try your idea just to see if it works.  Thanks.

Later,

Guy


On Tue, Sep 10, 2013 at 4:40 PM, Franklyn Tackitt <franklyn@tackitt.net>wrote:

> You may be able to edit the form.question.name attribute, but I havent
> tested this myself
>
>
> On Tue, Sep 10, 2013 at 1:27 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>
>> I actually need to change the fieldname key, not the value.  Here is what
>> I'm trying to do:
>>
>> 1st time form is displayed:
>>
>> <textarea name="question-1"></textarea> <!-- this is a question that the
>> user has not answered before -->
>> <textarea name="answer-32-question-2">Previous answer text</textarea><!--
>> this is a question that the user has answered before -->
>>
>> The user fills in an answer to question 1 and submits the form:
>>
>> I save the users answers to each question and redisplay the form.  I
>> can't use the name "question-1" for the fieldname anymore though.  I need
>> to the form to redisplay like this:
>>
>> <textarea name="*answer-53-question-1*"></textarea> <!-- now question 1
>> has been answered before-->
>> <textarea name="answer-32-question-2">Previous answer text</textarea><!--
>> this is a question that the user has answered before -->
>>
>> I posted a longer explanation a couple days ago that I think scared
>> everyone off!:
>> http://librelist.com/browser//flask/2013/9/8/create-a-multidict-in-flask/
>>
>>
>> On Tue, Sep 10, 2013 at 3:58 PM, Ryan O'Donnell <odonnellryanc@gmail.com>wrote:
>>
>>> This came up earlier: Just change form.fieldname.data to the value you'd
>>> like to have displayed. Does that answer your question or am I
>>> misunderstanding?
>>>
>>>
>>> On Tue, Sep 10, 2013 at 3:40 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>>>
>>>> Good idea Slater.  I didn't think of that.  I may have to resort to
>>>> that if I can't find a way to do it server side.  Thanks for sharing.
>>>>
>>>>
>>>> On Tue, Sep 10, 2013 at 3:27 PM, Slater Victoroff <
>>>> slater.r.victoroff@gmail.com> wrote:
>>>>
>>>>> If you know how the forms are identified in css you can change this
>>>>> with a small jQuery script. Something like:
>>>>>
>>>>> $("#form-field").eq(0).attr("name", "newName");
>>>>>
>>>>>
>>>>> On Tue, Sep 10, 2013 at 2:56 PM, Guy Jacks <guy.jacks@gmail.com>wrote:
>>>>>
>>>>>> Yes I am.
>>>>>>
>>>>>>
>>>>>> On Tue, Sep 10, 2013 at 2:40 PM, Ryan O'Donnell <
>>>>>> odonnellryanc@gmail.com> wrote:
>>>>>>
>>>>>>> Are you using WTForms?
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Sep 10, 2013 at 12:49 PM, Guy Jacks <guy.jacks@gmail.com>wrote:
>>>>>>>
>>>>>>>> Hi All,
>>>>>>>>
>>>>>>>> I have rare requirement in which I need to override the
>>>>>>>> request.form key,value pairs before displaying the form.  Can anyone show
>>>>>>>> me how to do this?
>>>>>>>>
>>>>>>>> The flow is that the user submits the form with data and then I
>>>>>>>> redisplay the form to the user with the values she entered.  The 
challenge
>>>>>>>> is that I need to change the names of the form fields before redisplaying
>>>>>>>> the form.
>>>>>>>>
>>>>>>>> Thank you,
>>>>>>>>
>>>>>>>> Guy Jacks
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Internet Strategist and Applications Architect
>>>>>>
>>>>>> mobile: 614.448.7649
>>>>>> guy.jacks@gmail.com
>>>>>> gtalk: guy.jacks
>>>>>> skype: guy.jacks
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Internet Strategist and Applications Architect
>>>>
>>>> mobile: 614.448.7649
>>>> guy.jacks@gmail.com
>>>> gtalk: guy.jacks
>>>> skype: guy.jacks
>>>>
>>>
>>>
>>
>>
>> --
>> Internet Strategist and Applications Architect
>>
>> mobile: 614.448.7649
>> guy.jacks@gmail.com
>> gtalk: guy.jacks
>> skype: guy.jacks
>>
>
>


-- 
Internet Strategist and Applications Architect

mobile: 614.448.7649
guy.jacks@gmail.com
gtalk: guy.jacks
skype: guy.jacks

Re: [flask] How can I override request.form values

From:
Guy Jacks
Date:
2013-09-10 @ 20:14
I actually need to change the fieldname key, not the value.  Here is what
I'm trying to do:

1st time form is displayed:

<textarea name="question-1"></textarea> <!-- this is a question that the
user has not answered before -->
<textarea name="answer-32-question-2">Previous answer text</textarea><!--
this is a question that the user has answered before -->

The user fills in an answer to question 1 and submits the form:

I save the users answers to each question and redisplay the form.  I can't
use the name "question-1" for the fieldname anymore though.  I need to the
form to redisplay like this:

<textarea name="*answer-53-question-1*"></textarea> <!-- now question 1 has
been answered before-->
<textarea name="answer-32-question-2">Previous answer text</textarea><!--
this is a question that the user has answered before -->

I posted a longer explanation a couple days ago that I think scared
everyone off!:
http://librelist.com/browser//flask/2013/9/8/create-a-multidict-in-flask/


On Tue, Sep 10, 2013 at 3:58 PM, Ryan O'Donnell <odonnellryanc@gmail.com>wrote:

> This came up earlier: Just change form.fieldname.data to the value you'd
> like to have displayed. Does that answer your question or am I
> misunderstanding?
>
>
> On Tue, Sep 10, 2013 at 3:40 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>
>> Good idea Slater.  I didn't think of that.  I may have to resort to that
>> if I can't find a way to do it server side.  Thanks for sharing.
>>
>>
>> On Tue, Sep 10, 2013 at 3:27 PM, Slater Victoroff <
>> slater.r.victoroff@gmail.com> wrote:
>>
>>> If you know how the forms are identified in css you can change this with
>>> a small jQuery script. Something like:
>>>
>>> $("#form-field").eq(0).attr("name", "newName");
>>>
>>>
>>> On Tue, Sep 10, 2013 at 2:56 PM, Guy Jacks <guy.jacks@gmail.com> wrote:
>>>
>>>> Yes I am.
>>>>
>>>>
>>>> On Tue, Sep 10, 2013 at 2:40 PM, Ryan O'Donnell <
>>>> odonnellryanc@gmail.com> wrote:
>>>>
>>>>> Are you using WTForms?
>>>>>
>>>>>
>>>>> On Tue, Sep 10, 2013 at 12:49 PM, Guy Jacks <guy.jacks@gmail.com>wrote:
>>>>>
>>>>>> Hi All,
>>>>>>
>>>>>> I have rare requirement in which I need to override the request.form
>>>>>> key,value pairs before displaying the form.  Can anyone show me how to do
>>>>>> this?
>>>>>>
>>>>>> The flow is that the user submits the form with data and then I
>>>>>> redisplay the form to the user with the values she entered.  The challenge
>>>>>> is that I need to change the names of the form fields before redisplaying
>>>>>> the form.
>>>>>>
>>>>>> Thank you,
>>>>>>
>>>>>> Guy Jacks
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Internet Strategist and Applications Architect
>>>>
>>>> mobile: 614.448.7649
>>>> guy.jacks@gmail.com
>>>> gtalk: guy.jacks
>>>> skype: guy.jacks
>>>>
>>>
>>>
>>
>>
>> --
>> Internet Strategist and Applications Architect
>>
>> mobile: 614.448.7649
>> guy.jacks@gmail.com
>> gtalk: guy.jacks
>> skype: guy.jacks
>>
>
>


-- 
Internet Strategist and Applications Architect

mobile: 614.448.7649
guy.jacks@gmail.com
gtalk: guy.jacks
skype: guy.jacks