Hi
I have a web2py application that I have recently upgraded to version 2.12.3
and have been working on converting it to use the jqmobile plugin. I have
run into an issue with form submission due to the url not changing when you
submit a form so rather than load the page specified by the
redirect(URL('')) in the controller function it just loads the existing
form again when I click on submit. I found some old posts that talk about
about using data-url to indicate what the page url is and if I add that to
my view manually eg:
{{extend 'plugin_jqmobile/layout.html'}}
<div class="title">
{{=H1(title)}}
</div>
<!-- Added to load inspect url -->
<div class="ui-page ui-body-c ui-page-active" data-role="page"
data-url="/BridgeSurvey/bridge/inspect" data-external-page="true"
tabindex="0" style="min-height: 450px;">
{{=form}}
I can get the url to change but the inspect form is not themed properly so
I was wondering if this parameter should be set in the controller function.
Just wondering if anyone can give me some advice on the best way to
approach this issue. The first three controls I am using are listed below.
def add():
form = SQLFORM(db.bridges,formstyle='divs')
if form.accepts(request.vars, session):
record = db(db.roads.id==form.vars.road_id).select()
vertadded = 'Bridge ' + str(form.vars.id) + ' chainage ' +
str(form.vars.chainage) + 'm on ' + record[0].name + ' road has been added
chose the inspector and click next'
session.vertadded = vertadded
session.bridgeid = form.vars.id
redirect(URL('inspect'))
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill out the form'
records=SQLTABLE(db().select(db.bridges.ALL))
return dict(form=form,record=records, title='Add a new bridge')
def inspect():
#form = SQLFORM(db.bridge_inspections,formstyle='divs')
form =
SQLFORM(db.bridge_inspections,formstyle='divs',submit_button='Next',fields=['inspector_id'])
if session.bridgeid:
form.vars.bridge_id = session.bridgeid
response.flash = str(form.vars.bridge_id)
if form.accepts(request.vars,session):
inspectionid = form.vars.id
session.inspectionid = inspectionid
message = 'form submitted, the inspection id is ' +
str(session.inspectionid)
response.flash = message
insertcheck(inspectionid)
redirect(URL('check'))
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill out the form'
return dict(form=form, title='Inspect a bridge')
def check():
inspectionid = session.inspectionid
#session.forget()
myform = SQLFORM(db.bridge_inspection_checklist)
if myform.accepts(request.vars,session):
row = db(db.bridge_inspection_checklist.id==form.vars.id).select()
row[0].update_record(bridge_inspection_id=inspectionid)
message = 'inspection id is ' + str(inspectionid) + ' - checklist
completed'
response.flash = message
redirect(URL('completeinspect'))
myrecords =
db(db.bridge_inspection_checklist.inspection_id==inspectionid).select()
if request.vars.multiple_update:
for r in myrecords:
if request.vars.has_key('id%i_problem' % r.id):
r.update_record(
problem=request.vars['id%i_problem' % r.id],
comment=request.vars['id%i_comment' % r.id],
rectified=request.vars['id%i_rectified' % r.id],
maintreq=request.vars['id%i_maintreq' % r.id],
inspectreq=request.vars['id%i_inspectreq' %r.id])
myrecords = db().select(db.bridge_inspection_checklist.ALL)
response.flash = 'checklist updated'
redirect(URL('completeinspect'))
elif myform.errors:
response.flash = 'form has errors'
else:
message = 'please complete the checklist for inspection ' +
str(inspectionid)
response.flash = message
return dict(form=myform,records=myrecords,title='Complete checklist')
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.