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
-~----------~----~----~----~------~----~------~--~---

Reply via email to