I have a function to update opening hours: @auth.requires_membership('homepage_manager') def update_openinghours(): openinghours=db(db.openinghours.company_id==auth.user.company_id)\ .select(db.openinghours.ALL) form=[] if not openinghours or request.vars.x: if not response.init_flash: response.init_flash='Insert opening hour' message='Opening hour inserted' form=create_form(db.openinghours,'update_openingshours',message=message) else: if not request.args: if not response.init_flash: response.init_flash='Opening hours in database' else: if not response.init_flash: response.init_flash='Update opening hour' message='Opening hour updated' form=update_form(db.openinghours,request.args[0],'update_openinghours', \ message=message,deletable=True) return dict(openinghours=openinghours,form=form)
In the create_form and update_form functions I add a cancel button to the form which redirects to the current page: def create_form(table,next,message): form=crud.create(table=table,next=(URL(r=request,f=next)),message=message) form[0][-1][1].append(INPUT(_type="button",_value="Cancel",\ _onclick="window.location='%s';"%URL(r=request,f=next))) return form def update_form(table,record,next,message,deletable): form=crud.update(table=table,record=record,next=(URL(r=request,f=next)),message=message,deletable=deletable) form[0][-1][1].append(INPUT(_type="button",_value="Cancel",\ _onclick="window.location='%s';"%URL(r=request,f=next))) return form In the view I have a link "insert record": <td><h4>{{=A('Insert record',_onmouseover="this.style.cursor='pointer';",\ _href=URL(r=request,f='update_openinghours',vars={'x':1}))}}</h4> </td> and the days are links: <td> {{=A(record.dag,_onmouseover="this.style.cursor='pointer';",\ _href=URL(r=request,f='update_openinghours',args=[record.id]))}} </td> The problem is everything works accept for the cancel button in the create_form, which results in an invalid function error when clicked. This I don't understand, while the url's of the cancel buttons in both the create_form and the update_form read the same, the cancel button in the update_form works, the form above the table containing the opening hours disappears and just the table is displayed. I hope one of you knows why this happens and how I can fix this problem. Kind regards, Annet.