Re: [web2py] conditional update after form is submitted
Thanks Batman, That is what I was looking for. I thought I had seen it before, but could not find it again when searching the documentation. Cheers Simon On Saturday, 10 November 2012 19:47:00 UTC, Niphlod wrote: > > or use the onvalidation callback on form.process > > form.process(onvalidation=yourfunction).accepted > > On Saturday, November 10, 2012 6:57:10 PM UTC+1, Vasile Ermicioi wrote: >> >> if form.validate(request.vars): >> #your code >> form.accepts(request.vars) > > --
Re: [web2py] conditional update after form is submitted
Hi Vasile, Thanks for the reply, but that code seems to generate an error if form.validate(request.vars): TypeError: validate() takes exactly 1 argument (2 given) Here is my full function that I am trying to run if it helps @auth.requires_login() def edit_chart(): record = db.section_charts(request.vars['scid']) form = SQLFORM(db.section_charts,record,Fields=('title','description','width','position'),deletable=True,hidden=dict(oldposition=record.position)) if form.validate(request.vars): if request.vars['oldposition'] != form.vars['position']: sql = "update section_charts set position = position + 1 where position >= " + str(form.vars['position']) db.executesql(sql) if form.process().accepted: response.flash = "Chart Updated" redirect(URL('manage_dashboard'),client_side=True) elif form.errors: response.flash = "The forms has errors" else: response.flash = "Please complete the form" return form On Saturday, 10 November 2012 17:57:10 UTC, Vasile Ermicioi wrote: > > if form.validate(request.vars): > #your code > form.accepts(request.vars) --
Re: [web2py] conditional update after form is submitted
or use the onvalidation callback on form.process form.process(onvalidation=yourfunction).accepted On Saturday, November 10, 2012 6:57:10 PM UTC+1, Vasile Ermicioi wrote: > > if form.validate(request.vars): > #your code > form.accepts(request.vars) --
Re: [web2py] conditional update after form is submitted
if form.validate(request.vars): #your code form.accepts(request.vars) --
[web2py] conditional update after form is submitted
Hi, I want to run some code after an update form is submitted but before the record in the database is updated. Where can I put the code so that I know the values in the form have passed validation before I run my code. Thanks Simon --