Do not use this:
form = crud.create(db.myTable,
next = URL(r=request, args=request.args),
message = 'record created')
use this instead:
form = SQLFORM(db.myTable)
if form.accepts(request.post_vars,formname=None):
session.flash='record created'
redirect(URL(r=request, args=request.args))
On Feb 10, 1:01 pm, anuj <[email protected]> wrote:
> Hi,
>
> I am using OpenLayers(http://openlayers.org) with web2py. I want to
> open a form on a map event. In the controller, I have a function
> def getForm():
> lon = request.args[0]
> lat = request.args[1]
> db.myTable.longitude.default = lon
> db.myTable.latitude.default = lat
> form = crud.create(db.myTable,
> next = URL(r=request, args=request.args),
> message = 'record created')
> return form;
>
> and another
> def getForm1():
> form = crud.create(db.myTable,
> next = URL(r=request, args=request.args),
> message = 'record created')
> return dict(form=form)
>
> I use it in a view as:
> var formURL = 'getForm/'+lon+'/'+lat;
> xmlhttp.open("POST", formURL, false);
> xmlhttp.send(null);
> var form = xmlhttp.responseText;
> document.getElementById('forms').innerHTML = form;
>
> Which shows the form alright when the map is clicked, but on
> submission the record is not added in the database.
> Where as in the view getForm1 if I use
> {{=form}}
> everything works fine. Can some one please tell me what I am doing
> wrong?
>
> Best regards,
> Anuj
--
You received this message because you are subscribed to the Google Groups
"web2py-users" 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.