[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Sushant Taneja
Thanks. Got that reply sometime after I posted. 
I have changed my code. I have now created an upload image component with a 
form and am using the LOAD() feature with ajax=False to get it working.

Thanks again for the reply. Helped a lot ! :)

On Monday, April 2, 2012 7:20:24 PM UTC+5:30, Anthony wrote:
>
> But as I stated above, the problem is the  element which contains the 
>> _formname and _formkey is not getting generated on the page for the image 
>> upload form and I think that it might be creating the problem.
>>
>> What can be the reason for it ?
>>
>
> Did you see my other reply? It sounds like you are not calling 
> form.accepts (or .process or .validate) when the form is initially created. 
> It will help if you show your current code.
>
> Anthony 
>


[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Anthony

>
> But as I stated above, the problem is the  element which contains the 
> _formname and _formkey is not getting generated on the page for the image 
> upload form and I think that it might be creating the problem.
>
> What can be the reason for it ?
>

Did you see my other reply? It sounds like you are not calling form.accepts 
(or .process or .validate) when the form is initially created. It will help 
if you show your current code.

Anthony 


[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Sushant Taneja
Thanks Anthony. 

But as I stated above, the problem is the  element which contains the 
_formname and _formkey is not getting generated on the page for the image 
upload form and I think that it might be creating the problem.

What can be the reason for it ?


On Monday, April 2, 2012 6:29:41 PM UTC+5:30, Anthony wrote:
>
> I tried with form.validate() and also with form.process().accepted. Can 
>> you provide some sample code on how do I achieve the above ?
>> I am already providing the name of the form while declaring it. How is it 
>> different from web2py generated _formname ?
>>
>
> Your original code simply set the "name" attribute of the HTML  
> element (i.e., SQLFORM(..., _name=...)). However, that doesn't affect the 
> _formname hidden element. To set that, you have to set the "formname" 
> argument to the accepts() method (or process() or validate()).  Anyway, 
> I'm not sure you need to set your own formname -- web2py will automatically 
> generate a formname based on the db table name and type of form, so two 
> forms on the same page based on different tables will have different names 
> anyway. See 
> http://web2py.com/books/default/chapter/29/7#Multiple-forms-per-page.
>
> Anthony
>


[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Anthony

>
> I also checked using chrome developer tools that the  which contains 
> the _formkey and _formname is not getting generated (missing from HTML). 
> May be that is the reason the form is not working.
>
> What may be the reason for this ? and what is a feasible solution ?
>

Sounds like you're not calling form.accepts (or .process or .validate) when 
the form is first created before returning it to the view. It might help if 
you show your current code.

Anthony


[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Anthony

>
> I tried with form.validate() and also with form.process().accepted. Can 
> you provide some sample code on how do I achieve the above ?
> I am already providing the name of the form while declaring it. How is it 
> different from web2py generated _formname ?
>

Your original code simply set the "name" attribute of the HTML  
element (i.e., SQLFORM(..., _name=...)). However, that doesn't affect the 
_formname hidden element. To set that, you have to set the "formname" 
argument to the accepts() method (or process() or validate()).  Anyway, I'm 
not sure you need to set your own formname -- web2py will automatically 
generate a formname based on the db table name and type of form, so two 
forms on the same page based on different tables will have different names 
anyway. 
See http://web2py.com/books/default/chapter/29/7#Multiple-forms-per-page.

Anthony


[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-02 Thread Sushant Taneja
I also checked using chrome developer tools that the  which contains 
the _formkey and _formname is not getting generated (missing from HTML). 
May be that is the reason the form is not working.

What may be the reason for this ? and what is a feasible solution ? 

On Monday, April 2, 2012 10:55:51 AM UTC+5:30, Sushant Taneja wrote:
>
> Hi,
>
> I tried with form.validate() and also with form.process().accepted. Can 
> you provide some sample code on how do I achieve the above ?
> I am already providing the name of the form while declaring it. How is it 
> different from web2py generated _formname ?
>
> On Monday, April 2, 2012 5:07:14 AM UTC+5:30, Anthony wrote:
>>
>> In the method which defines the registration form, I return upload_form 
>>> alongside as :
>>>
>>> return(reg_form=reg_form,upload_form=upload_form)
>>>
>>> The problem is that the _formkey and _formname hidden fields are created 
>> when you call form.accepts() -- so you have to call form.accepts() both 
>> when the form is first created and returned to the view and when the form 
>> is submitted. The form object that you are returning to the view does not 
>> include those hidden fields, but the form processing code in upload_image() 
>> is expecting those fields to be there. Also, it is recommended that you use 
>> the newer form.process() or form.validate() API rather than form.accepts().
>>
>> Anthony
>>
>>

[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-01 Thread Sushant Taneja
Hi,

I tried with form.validate() and also with form.process().accepted. Can you 
provide some sample code on how do I achieve the above ?
I am already providing the name of the form while declaring it. How is it 
different from web2py generated _formname ?

On Monday, April 2, 2012 5:07:14 AM UTC+5:30, Anthony wrote:
>
> In the method which defines the registration form, I return upload_form 
>> alongside as :
>>
>> return(reg_form=reg_form,upload_form=upload_form)
>>
>> The problem is that the _formkey and _formname hidden fields are created 
> when you call form.accepts() -- so you have to call form.accepts() both 
> when the form is first created and returned to the view and when the form 
> is submitted. The form object that you are returning to the view does not 
> include those hidden fields, but the form processing code in upload_image() 
> is expecting those fields to be there. Also, it is recommended that you use 
> the newer form.process() or form.validate() API rather than form.accepts().
>
> Anthony
>
>

[web2py] Re: Multiple custom SQLFORMs on a page only able to submit one.

2012-04-01 Thread Anthony

>
> In the method which defines the registration form, I return upload_form 
> alongside as :
>
> return(reg_form=reg_form,upload_form=upload_form)
>
> The problem is that the _formkey and _formname hidden fields are created 
when you call form.accepts() -- so you have to call form.accepts() both 
when the form is first created and returned to the view and when the form 
is submitted. The form object that you are returning to the view does not 
include those hidden fields, but the form processing code in upload_image() 
is expecting those fields to be there. Also, it is recommended that you use 
the newer form.process() or form.validate() API rather than form.accepts().

Anthony