thanks , it worked. i was thinking to use sqlform factory to create a form
and push it into database.
On Sunday, September 16, 2012 7:45:39 PM UTC+4:30, Anthony wrote:
>
> The problem is not that you are changing the validator in each form
> function -- the form always gets submitted back to its original function,
> so the validator will always be set the same, both on form creation and
> form submission/validation. The problem is that when you create the form,
> it gets a default name and a hidden _formkey field associated with that
> name. The _formkey is also stored in the session and used to prevent CSRF
> attacks and double submission. When you create form2, it overwrites the
> _formkey value of form1 in the session because both forms have the same
> name. If you then try to submit form1, it won't validate. To solve the
> problem, just give each form a unique name:
>
> form.process(..., formname='form1')
>
> Anthony
>
> On Sunday, September 16, 2012 7:12:52 AM UTC-4, yashar wrote:
>>
>> below solution not working, because when you open form1 then form2,
>> web2py will look for joe for field, and not saving form1, so how could i
>> solve it?
>>
>> db.define_table('test',
>> Field('name'))
>>
>> def form1():
>> db.test.name.requires=IS_IN_SET(['yashar'])
>> form = SQLFORM(db.test)
>> if form.process().accepted:
>> pass
>> return dict(form=form)
>>
>> def form2():
>> db.test.name.requires=IS_IN_SET(['Joe'])
>> form = SQLFORM(db.test)
>> if form.process().accepted:
>> pass
>> return dict(form=form)
>>
>>
>>
>>
--