Hi everybody. I' been analyzing the case and maybe the problem is related to the line " form3=FORM() " at the controller. This line is inside a IF statement and form3 is the one that triggers the error when it's submitted.
When no ID is selected form3=FORM(), when an ID is selected form3=SQLFORM (db.rec_obj,submit_button='Agregar',_formname='f3') Is there any other way to define an empty form so this form is not displayed when no ID is selected? Thanks! Juan On Feb 17, 4:59 pm, Juan Andres Ramil <[email protected]> wrote: > Sorry, I forget to include the view (abm_recurso.html) for the controller. > This view is important because it will give you the posibility to select a > particular value to edit. > The code of the view is: > > {{extend 'layout.html'}} > <h1>ABM Recursos</h1> > {{=form1}} > {{=form2}} > <table> > {{if records2!=None: }} > {{for rec_obj in records2:}} > <tr> > <td>{{=rec_obj.objetivo.descripcion}}<td> > </tr> > {{pass}} > {{pass}} > </table> > {{=form3}} > <table> > {{for recurso in records:}} > <tr> > <td>{{=A(recurso.id,_href=URL(r=request,f='abm_recurso?id=%s'% > recurso.id))}}<td> > <td>{{=recurso.nombre}}<td> > </tr> > {{pass}} > </table> > > The steps needed to reproduce the error are the following: > > 1.- Insert a dummy record at db.objetivo > 2.- Go to abm_recurso page > 3.- Insert into the "Nombre" field any value and click on "Agregar" (at this > point the new record should be displayed at the end of the page). > 4.- Click on the ID of the recently added value. The page should change and > give you the possibility to modify record or to add a new relationship > between "recurso" and "objetivo" > At this point you should have three buttons called "Modificar" "Nuevo > Recurso" and "Agregar" > 5.- Click on "Agregar" with the selected values at the form at the fields > "recurso" and "objetivo". > > At this point, the error should happend. > Let me know if you need any other detail. Thanks! > > Juan > > 2009/2/17 mdipierro <[email protected]> > > > > > I cannot reproduce the problem. Can you send me an applicance > > containing some data and a step by step example to reproduce it? > > > Massimo > > > On Feb 17, 7:09 am, vamaq <[email protected]> wrote: > > > Continuing with the exercise; I've added some additional complexity to > > > the controller. The problem is that I'm getting the "user is tampering > > > with form" error again. > > > > Details: > > > > - I'm working with the update revision 729 at SVN (Python 2.5.4) > > > - The model continues to be the same. > > > - The error is raised when I submit either form3 or form2. > > > - form1: handles all the actions on "recurso" > > > - form2: Is only a button to clean and start again. (Submitting this > > > form rise an error) > > > - form3: at the moment only gives the possibility to chose one > > > "recurso" and one "objetivo" and create a relationship. (Submitting > > > this form rise an error) > > > > Objective: > > > > - The final idea is to create a simple page that allows to add / > > > modify / delete "recursos" and also gives to the user the possibility > > > to specify relationships with many "objetivos". > > > - The controller is not yet completed. But in theory it should work > > > (obviously is not) > > > > Following is the new controller and finally is the error stack. > > > Thanks for your help! > > > > Juan > > > > ################################ Controller > > > ######################################## > > > > def abm_recurso(): > > > > if request.vars.has_key('id'): records=db > > > (db.recurso.id==request.vars.id).select() > > > > if request.vars.has_key('id') and len(records): > > > > form1=SQLFORM(db.recurso,records > > > [0],deletable=True,submit_button='Modificar') > > > > rec_obj=db((db.recurso.id==db.rec_obj.recurso)& > > > (db.objetivo.id==db.rec_obj.objetivo)& > > > (db.recurso.id==request.vars.id)) > > > records2=rec_obj.select() > > > > form3=SQLFORM > > > (db.rec_obj,submit_button='Agregar',_formname='f3') > > > > else: > > > > form1=SQLFORM(db.recurso,submit_button='Agregar') > > > form3=FORM() > > > records2='' > > > > form2=FORM(INPUT(_type='submit',_name='NuevoRecurso',_value='Nuevo > > > Recurso')) > > > > if form1.accepts(request.vars,session,formname='form1') and > > > request.vars.has_key('id'): redirect(URL(r=request,f='abm_recurso')) # > > > to clean the form. > > > if form2.accepts(request.vars,session,formname='form2'): redirect > > > (URL(r=request,f='abm_recurso')) # to clean the form. > > > form3.accepts(request.vars,session,formname='form3') > > > > if form1.errors: response.flash='Form has Errors' > > > if form3.errors: response.flash='Form has Errors' > > > > records=db().select(db.recurso.ALL) > > > > return dict > > > (form1=form1,form2=form2,form3=form3,records=records,records2=records2) > > > > ################################ Error > > > ######################################## > > > > Traceback (most recent call last): > > > File "f:\Web2Py\web2py.dev\gluon\restricted.py", line 98, in > > > restricted > > > exec ccode in environment > > > File "f:/Web2Py/web2py.dev/applications/Recursos/controllers/ > > > default.py", line 70, in <module> > > > File "f:\Web2Py\web2py.dev\gluon\globals.py", line 75, in <lambda> > > > self._caller = lambda f: f() > > > File "f:/Web2Py/web2py.dev/applications/Recursos/controllers/ > > > default.py", line 30, in abm_recurso > > > form3.accepts(request.vars,session,formname='form3') > > > File "f:\Web2Py\web2py.dev\gluon\sqlhtml.py", line 482, in accepts > > > raise SyntaxError, 'user is tampering with form' > > > SyntaxError: user is tampering with form > > > > On Feb 17, 9:08 am, Juan Andres Ramil <[email protected]> > > > wrote: > > > > > Yes it's working perfectly. > > > > Thanks! > > > > > Juan > > > > > 2009/2/15 mdipierro <[email protected]> > > > > > > I believe this is fixed now in trunk but needs to be tested. Can you > > > > > please try it works with your code? > > > > > > Massimo > > > > > > On Feb 15, 9:15 am, mdipierro <[email protected]> wrote: > > > > > > Yes this is a bug introduced in one of the recent versions. It > > > > > > prevents multiple forms on the same page. I will fit later today. > > > > > > > Massimo > > > > > > > On Feb 13, 2:41 pm, vamaq <[email protected]> wrote: > > > > > > > > Hi everybody, > > > > > > > > I'm having a problem with a multiple form page. When I submit the > > > > > > > first form (called form) I get the "user is tampering with form" > > error > > > > > > > at the trace. > > > > > > > > The model is: > > > > > > > > db=SQLDB('sqlite://storage.db') > > > > > > > > db.define_table('recurso', > > > > > > > SQLField('nombre','string',length=100,notnull=True)) > > > > > > > db.recurso.nombre.requires=[IS_NOT_IN_DB > > > > > > > (db,'recurso.nombre'),IS_NOT_EMPTY()] > > > > > > > > db.define_table('objetivo', > > > > > > > SQLField('descripcion','string',length=100,notnull=True, > > requires= > > > > > > > [IS_NOT_IN_DB(db,'objetivo.descripcion'),IS_NOT_EMPTY()])) > > > > > > > > db.define_table('rec_obj', > > > > > > > SQLField('recurso',db.recurso), > > > > > > > SQLField('objetivo',db.objetivo)) > > > > > > > db.rec_obj.recurso.requires=IS_IN_DB(db,'recurso.id') > > > > > > > db.rec_obj.objetivo.requires=IS_IN_DB(db,'objetivo.id') > > > > > > > > The controller is: > > > > > > > > def index(): > > > > > > > > records=db(db.recurso.id==11).select() > > > > > > > > form=SQLFORM(db.recurso,records[0],deletable=True) > > > > > > > form3=SQLFORM(db.rec_obj) > > > > > > > > form.accepts(request.vars,session,formname='myform1') > > > > > > > form3.accepts(request.vars,session,formname='myform2') > > > > > > > > if form.errors: response.flash='Form has Errors' > > > > > > > if form3.errors: response.flash='Form has Errors' > > > > > > > > return dict(form1=form,form3=form3) > > > > > > > > I will appreciate any guidance. > > > > > > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

