I have a basic update form code that is called via a HREF form another
view and form a menu.  The problem is the redirect to the referrer is
not working.  I looked in the forums and have tried to debug.  I
understand the form is posting back to itself which is why the form is
redirected to itself.  The forums offer several solutions that depend
on a hidden form element embedded in the calling view which are save
as request.vars.  I am not sure how to make this work with a menu.  I
hope there is a clean elegant way to accomplish this.  Any help would
be apprecaited..

@auth.requires_login()
def editmeeting():
    if not request.args:
        session.flash = 'Invalid parameter'
        redirect(URL(r=request, c='default',
f='index'))
    meeting = db(db.meeting.id == request.args(0)).select()
    if len(meeting):
        meeting = meeting[0]
    else:
        session.flash = 'Invalid meeting'
        redirect(URL(r=request,c='default',f='index'))
    form=SQLFORM(db.meeting,meeting, submit_button='Update Meeting')
    if form.accepts(request.vars, session):
        redirect(request.env.http_referer)
    elif form.errors:
        response.flash = 'Invalid data.'
    return dict(form=form)

Reply via email to