librelist archives

« back to archive

Several forms to be handled in one view function

Several forms to be handled in one view function

From:
Andriy Yurchuk
Date:
2011-11-04 @ 15:58
If I have several forms on a page and a single view function for them, 
how do I determine which of them was submitted in the "if request.method 
== 'POST':" construct?

-- 
Regards,
Andriy Yurchuk

Re: [flask] Several forms to be handled in one view function

From:
Andy Wilson
Date:
2011-11-04 @ 16:36
On each of the forms, add a hidden input element with a distinct
value. Then check that value when you process the incoming form in the
view.


On Fri, Nov 4, 2011 at 10:58 AM, Andriy Yurchuk <ayurchuk@minuteware.net> wrote:
> If I have several forms on a page and a single view function for them,
> how do I determine which of them was submitted in the "if request.method
> == 'POST':" construct?
>
> --
> Regards,
> Andriy Yurchuk
>
>
>

Re: [flask] Several forms to be handled in one view function

From:
Andriy Yurchuk
Date:
2011-11-04 @ 20:43
I'm kind of stuck with this. The Add button works as expected, but the 
Delete one does not. Clicking it does not give any result (no requests 
are sent). I'll appreciate if you could take a look at my code here: 
http://pastebin.com/732ttgRN There are my template and the view 
function.

Thanks ahead.

---
Regards,
Andriy Yurchuk

On Fri, 4 Nov 2011 11:36:38 -0500, Andy Wilson wrote:
> On each of the forms, add a hidden input element with a distinct
> value. Then check that value when you process the incoming form in 
> the
> view.
>
>
> On Fri, Nov 4, 2011 at 10:58 AM, Andriy Yurchuk
> <ayurchuk@minuteware.net> wrote:
>> If I have several forms on a page and a single view function for 
>> them,
>> how do I determine which of them was submitted in the "if 
>> request.method
>> == 'POST':" construct?
>>
>> --
>> Regards,
>> Andriy Yurchuk
>>
>>
>>

Re: [flask] Several forms to be handled in one view function

From:
Andy Wilson
Date:
2011-11-04 @ 20:55
Looks like the form that starts at line 20 is not being closed before
the form at line 44 begins. And then there are two closing form tags
at the end. Then your delete submit is outside of all of them so it
isn't associated with any form and that's why nothing happens when you
click it.


On Fri, Nov 4, 2011 at 3:43 PM, Andriy Yurchuk <ayurchuk@minuteware.net> wrote:
> I'm kind of stuck with this. The Add button works as expected, but the
> Delete one does not. Clicking it does not give any result (no requests
> are sent). I'll appreciate if you could take a look at my code here:
> http://pastebin.com/732ttgRN There are my template and the view
> function.
>
> Thanks ahead.
>
> ---
> Regards,
> Andriy Yurchuk
>
> On Fri, 4 Nov 2011 11:36:38 -0500, Andy Wilson wrote:
>> On each of the forms, add a hidden input element with a distinct
>> value. Then check that value when you process the incoming form in
>> the
>> view.
>>
>>
>> On Fri, Nov 4, 2011 at 10:58 AM, Andriy Yurchuk
>> <ayurchuk@minuteware.net> wrote:
>>> If I have several forms on a page and a single view function for
>>> them,
>>> how do I determine which of them was submitted in the "if
>>> request.method
>>> == 'POST':" construct?
>>>
>>> --
>>> Regards,
>>> Andriy Yurchuk
>>>
>>>
>>>
>
>

Re: [flask] Several forms to be handled in one view function

From:
Andriy Yurchuk
Date:
2011-11-04 @ 21:04
Form tags are OK, but the Delete button indeed was outside of the form. 
Thanks for taking a look!

---
Regards,
Andriy Yurchuk

On Fri, 4 Nov 2011 15:55:12 -0500, Andy Wilson wrote:
> Looks like the form that starts at line 20 is not being closed before
> the form at line 44 begins. And then there are two closing form tags
> at the end. Then your delete submit is outside of all of them so it
> isn't associated with any form and that's why nothing happens when 
> you
> click it.
>
>
> On Fri, Nov 4, 2011 at 3:43 PM, Andriy Yurchuk
> <ayurchuk@minuteware.net> wrote:
>> I'm kind of stuck with this. The Add button works as expected, but 
>> the
>> Delete one does not. Clicking it does not give any result (no 
>> requests
>> are sent). I'll appreciate if you could take a look at my code here:
>> http://pastebin.com/732ttgRN There are my template and the view
>> function.
>>
>> Thanks ahead.
>>
>> ---
>> Regards,
>> Andriy Yurchuk
>>
>> On Fri, 4 Nov 2011 11:36:38 -0500, Andy Wilson wrote:
>>> On each of the forms, add a hidden input element with a distinct
>>> value. Then check that value when you process the incoming form in
>>> the
>>> view.
>>>
>>>
>>> On Fri, Nov 4, 2011 at 10:58 AM, Andriy Yurchuk
>>> <ayurchuk@minuteware.net> wrote:
>>>> If I have several forms on a page and a single view function for
>>>> them,
>>>> how do I determine which of them was submitted in the "if
>>>> request.method
>>>> == 'POST':" construct?
>>>>
>>>> --
>>>> Regards,
>>>> Andriy Yurchuk
>>>>
>>>>
>>>>
>>
>>

Re: [flask] Several forms to be handled in one view function

From:
Oliver Berger
Date:
2011-11-15 @ 21:55
May be you solved it already, but in your code the delete button is
disabled, thus doing nothing as you already said:

<input class=delete type=submit value=Delete disabled>

I would also suggest to use some kind of Form/widget library to avoid
redundant markup


regards,
Oliver



On 04.11.2011 22:04, Andriy Yurchuk wrote:
> Form tags are OK, but the Delete button indeed was outside of the form. 
> Thanks for taking a look!
> 
> ---
> Regards,
> Andriy Yurchuk
> 
> On Fri, 4 Nov 2011 15:55:12 -0500, Andy Wilson wrote:
>> Looks like the form that starts at line 20 is not being closed before
>> the form at line 44 begins. And then there are two closing form tags
>> at the end. Then your delete submit is outside of all of them so it
>> isn't associated with any form and that's why nothing happens when 
>> you
>> click it.
>>
>>
>> On Fri, Nov 4, 2011 at 3:43 PM, Andriy Yurchuk
>> <ayurchuk@minuteware.net> wrote:
>>> I'm kind of stuck with this. The Add button works as expected, but 
>>> the
>>> Delete one does not. Clicking it does not give any result (no 
>>> requests
>>> are sent). I'll appreciate if you could take a look at my code here:
>>> http://pastebin.com/732ttgRN There are my template and the view
>>> function.
>>>
>>> Thanks ahead.
>>>
>>> ---
>>> Regards,
>>> Andriy Yurchuk
>>>
>>> On Fri, 4 Nov 2011 11:36:38 -0500, Andy Wilson wrote:
>>>> On each of the forms, add a hidden input element with a distinct
>>>> value. Then check that value when you process the incoming form in
>>>> the
>>>> view.
>>>>
>>>>
>>>> On Fri, Nov 4, 2011 at 10:58 AM, Andriy Yurchuk
>>>> <ayurchuk@minuteware.net> wrote:
>>>>> If I have several forms on a page and a single view function for
>>>>> them,
>>>>> how do I determine which of them was submitted in the "if
>>>>> request.method
>>>>> == 'POST':" construct?
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Andriy Yurchuk
>>>>>
>>>>>
>>>>>
>>>
>>>
>