in my controller, i tried

    if form.accepts(...):
        ...
    else:
        ...

Turns out the control is never passed back here on form submission. I
am using AJAX to call a function which returns the form HTML as text
and embed that into a div's innerHTML. Any ideas?

On Feb 11, 10:10 am, anuj <[email protected]> wrote:
> With
>
>     form = SQLFORM(...)
>
> the form added on the page has the flashing messages 'enter a value'
> for each field. And upon entering the values and submitting, still
> doesnt add to database.
> On Feb 11, 6:12 am, mdipierro <[email protected]> wrote:
>
> > 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.

Reply via email to