Now, I got it! Thanks! :-)
On 13 out, 22:04, "mr.freeze" <nat...@freezable.com> wrote: > It's the form name. You may not need it. _formname is necessary for > pages that contain and process multiple forms. It is added to the > form during form.accepts along with _formkey to prevent double > submission. More info on page 201 (labeled 185) in the manual. Glad > it worked! > > In general, it is best to avoid the web2py_ajax.html ajax function for > anything complicated. It is a simple helper to get people started but > has several limitations. > > On Oct 13, 7:55 pm, Renato-ES-Brazil <caliari.ren...@gmail.com> wrote: > > > mr.freeze, > > > ************** > > It worked! Thank you very much!!! :-) > > ************** > > > Doubt: > > #1 I don't understand very well about the hidden field > > "product_create". Could you explain? > > Note: I've not used it in my new code. > > > On 13 out, 21:30, "mr.freeze" <nat...@freezable.com> wrote: > > > > There are a couple of problems I think: > > > > There is a hidden field called "product_create" that needs to be sent > > > back too: > > > <input type="hidden" value="product_create" name="_formname"/> > > > > The built in ajax function explicitly grabs fields by ID which won't > > > work for you since it will send request.vars.product_name instead of > > > request.vars.name and won't grab the hidden field. Try using > > > jQuery.ajax and the serialize function to grab the data: > > > > def create_popup(): > > > script_submit = SCRIPT("""jQuery('#%(form)s').submit(function(){ > > > jQuery.ajax({ > > > type: "POST", > > > url: "%(url_ajax)s", > > > data: jQuery("#form_test").serialize(), > > > success: function(msg){jQuery('#message').html(msg);} }); > > > return false;});""" % {"form":"form_test", "url_ajax":URL > > > > (r=request,f='validate_popup')} ) > > > form = SQLFORM(db.product, _enctype=None, > > > _id="form_test",_action=None, _method=None) > > > return dict(form=form,script_submit=script_submit,message=DIV > > > (_id="message")) > > > > def validate_popup(): > > > form = SQLFORM(db.product) > > > if form.accepts(request.vars): > > > return DIV("Product successfully registered!") > > > elif form.errors: > > > return TABLE(*[TR(k, v) for k, v in form.errors.items()]) > > > else: return DIV("Nope") > > > > Hope that helps. > > > > On Oct 13, 6:01 pm, Renato-ES-Brazil <caliari.ren...@gmail.com> wrote: > > > > > Fixing: > > > > The code that I posted had a error because I'd edited manually here. > > > > The error was: > > > > "_id=form_name" instead of "_id="form_test". See below: > > > > > > form = SQLFORM(db.product, _enctype=None, _id=form_name, > > > > > _action=None, _method=None) > > > > > The correct line is: > > > > form = SQLFORM(db.product, _enctype=None, _id="form_test", > > > > _action=None, _method=None) > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---