form1 and form2 are just variables' names - they store the same HTML helper code. Notice that *_name='name' *is just a general example. Maybe it would be a little bit clearer if the _name values in the book were different: form_one, form_two. But that's basically it. You need to distinguish the forms you submit and it's not an only-web2py feature.
On Saturday, August 3, 2013 2:00:29 AM UTC+2, lyn2py wrote: > > Thanks Niphlod. But I thought that was accomplished with form1 and form2 > variables already? Do we still need to use the formname variable? > > On Saturday, August 3, 2013 12:20:26 AM UTC+8, Niphlod wrote: >> >> given that forms are submitted to the same page, it's the only way for >> the controller to know what form was indeed submitted :D >> >> On Friday, August 2, 2013 6:19:20 PM UTC+2, lyn2py wrote: >>> >>> From the book: >>> >>> def two_forms(): >>> >>> form1 = FORM(INPUT(_name='name', requires=IS_NOT_EMPTY()), >>> INPUT(_type='submit')) >>> form2 = FORM(INPUT(_name='name', requires=IS_NOT_EMPTY()), >>> INPUT(_type='submit')) >>> if form1.process(*formname='form_one'*).accepted: >>> response.flash = 'form one accepted' >>> if form2.process(*formname='form_two'*).accepted: >>> response.flash = 'form two accepted' >>> return dict(form1=form1, form2=form2) >>> >>> >>> I would like to ask the purpose of using formname='form_one'? >>> >>> Is it necessary? What does it do? >>> >>> >>> Thanks! >>> >>> -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

